forked from ovr/phpsa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Danny van der Sluijs
committed
Oct 5, 2016
1 parent
348c992
commit 7fe88e7
Showing
3 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Tests\PHPSA; | ||
|
||
use PHPSA\Application; | ||
|
||
class ApplicationTest extends TestCase | ||
{ | ||
/** | ||
* @covers \PHPSA\Application::__construct | ||
*/ | ||
public function testConstructor() | ||
{ | ||
$application = new Application(); | ||
|
||
$this->assertInstanceOf('\PHPSA\Application', $application); | ||
$this->assertInstanceOf('\Symfony\Component\Console\Application', $application); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\Application::getConfiguration | ||
*/ | ||
public function testGetConfiguration() | ||
{ | ||
$application = new Application(); | ||
|
||
$this->assertInstanceOf('\PHPSA\Configuration', $application->getConfiguration()); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\Application::getIssuesCollector | ||
*/ | ||
public function testGetIssueCollector() | ||
{ | ||
$application = new Application(); | ||
|
||
$this->assertInstanceOf('\PHPSA\IssuesCollector', $application->getIssuesCollector()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* phpsa | ||
* | ||
* PHP Version 7 | ||
* | ||
* @link http://scm.monitorlinq.com/backend | ||
* @copyright Copyright (c) 2016 Monitorlinq Limited | ||
* @license http://www.monitorlinq.com/license Proprietary License | ||
*/ | ||
|
||
namespace Tests\PHPSA; | ||
|
||
use PHPSA\IssuesCollector; | ||
|
||
class IssuesCollectorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @covers \PHPSA\IssuesCollector::addIssue() | ||
* @covers \PHPSA\IssuesCollector::getIssues() | ||
*/ | ||
public function testAddingIssue() | ||
{ | ||
$collector = new IssuesCollector(); | ||
|
||
$this->assertNull($collector->addIssue(100, 'Test issue', __FILE__, 26)); | ||
$this->assertCount(1, $collector->getIssues()); | ||
$this->assertSame( | ||
[['type' => 100, 'message' => 'Test issue', 'file' => __FILE__, 'line' => 26]], | ||
$collector->getIssues() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
namespace Tests\PHPSA; | ||
|
||
use PHPSA\ScopePointer; | ||
|
||
class ScopePointerTest extends TestCase | ||
{ | ||
/** | ||
* @covers \PHPSA\ScopePointer::__construct | ||
*/ | ||
public function testConstructor() | ||
{ | ||
$object = new \stdClass; | ||
$scopePointer = new ScopePointer($object); | ||
|
||
$this->assertInstanceOf('\PHPSA\ScopePointer', $scopePointer); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\ScopePointer::getObject | ||
*/ | ||
public function testGetObject() | ||
{ | ||
$object = new \stdClass; | ||
$scopePointer = new ScopePointer($object); | ||
|
||
$this->assertSame($object, $scopePointer->getObject()); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\ScopePointer::isClassMethod() | ||
*/ | ||
public function testIsClassMethod() | ||
{ | ||
$class = $this->getMockBuilder('\PHPSA\Definition\ClassMethod') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$scopePointer = new ScopePointer($class); | ||
|
||
$this->assertTrue($scopePointer->isClassMethod()); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\ScopePointer::isClassMethod() | ||
* @dataProvider notClassMethodDataProvider | ||
*/ | ||
public function testIsNotClassMethod($object) | ||
{ | ||
$scopePointer = new ScopePointer($object); | ||
|
||
$this->assertFalse($scopePointer->isClassMethod()); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\ScopePointer::isFunction() | ||
*/ | ||
public function testIsFunction() | ||
{ | ||
$function = $this->getMockBuilder('\PHPSA\Definition\FunctionDefinition') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$scopePointer = new ScopePointer($function); | ||
|
||
$this->assertTrue($scopePointer->isFunction()); | ||
} | ||
|
||
/** | ||
* @covers \PHPSA\ScopePointer::isFunction() | ||
* @dataProvider notFunctionDataProvider | ||
*/ | ||
public function testIsNotFunction($object) | ||
{ | ||
$scopePointer = new ScopePointer($object); | ||
|
||
$this->assertFalse($scopePointer->isFunction()); | ||
} | ||
|
||
public function notClassMethodDataProvider() | ||
{ | ||
$function = $this->getMockBuilder('\PHPSA\Definition\FunctionDefinition') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
return [ | ||
'String' => ['Random characters'], | ||
'Integer' => [42], | ||
'Float' => [pi()], | ||
'StdClass' => [new \StdClass], | ||
'FunctionDefinition' => [$function] | ||
]; | ||
} | ||
|
||
public function notFunctionDataProvider() | ||
{ | ||
$class = $this->getMockBuilder('\PHPSA\Definition\ClassMethod') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
return [ | ||
'String' => ['Random characters'], | ||
'Integer' => [42], | ||
'Float' => [pi()], | ||
'StdClass' => [new \StdClass], | ||
'ClassMethod' => [$class] | ||
]; | ||
} | ||
} |