-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests and fix related issues
- Loading branch information
Showing
33 changed files
with
755 additions
and
30 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
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,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false" | ||
verbose="true" | ||
bootstrap="vendor/autoload.php"> | ||
|
||
<php> | ||
<ini name="memory_limit" value="-1"/> | ||
</php> | ||
|
||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
<exclude> | ||
<!--Don't want to measure code coverage from test classes.--> | ||
<directory suffix=".php">tests</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
<testsuites> | ||
<testsuite name="Synopsis"> | ||
<directory suffix=".php">tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
*/ | ||
class ArraySynopsis extends AbstractSynopsis | ||
{ | ||
|
||
/** | ||
* @see parent::process() | ||
* @param $value | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
*/ | ||
class BooleanSynopsis extends AbstractSynopsis | ||
{ | ||
|
||
/** | ||
* @see parent::process() | ||
* @param $value | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
*/ | ||
class DoubleSynopsis extends AbstractSynopsis | ||
{ | ||
|
||
/** | ||
* @see parent::process() | ||
* @param $value | ||
|
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
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
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
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
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
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
*/ | ||
class IteratorSynopsis extends ObjectSynopsis | ||
{ | ||
|
||
/** | ||
* @see parent::process() | ||
* @param $value | ||
|
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
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
*/ | ||
class ObjectSynopsis extends AbstractSynopsis | ||
{ | ||
|
||
/** | ||
* @var string the namespace | ||
*/ | ||
|
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
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
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
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,54 @@ | ||
<?php | ||
|
||
namespace TheIconic\Synopsis; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Exception; | ||
use TheIconic\Synopsis\AbstractSynopsis; | ||
use TheIconic\Synopsis\ArraySynopsis; | ||
use TheIconic\Synopsis\Factory; | ||
use TheIconic\Synopsis\StringSynopsis; | ||
|
||
class ArraySynopsisTest extends TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testProcess() | ||
{ | ||
$synopsis = new ArraySynopsis(); | ||
$synopsis->setFactory($this->getMockFactory()); | ||
$synopsis->process([ | ||
'a' => 'b', | ||
'c' => 'd', | ||
], 3); | ||
|
||
$this->assertEquals('array', $synopsis->getType()); | ||
$this->assertEquals(2, $synopsis->getLength()); | ||
$this->assertEquals('', $synopsis->getValue()); | ||
$this->assertTrue($synopsis->hasChildren()); | ||
|
||
$children = $synopsis->getChildren(); | ||
$this->assertCount(2, $children); | ||
|
||
$this->assertEquals(1, $children['a']); | ||
$this->assertEquals(2, $children['c']); | ||
} | ||
|
||
/** | ||
* @return Factory | ||
*/ | ||
protected function getMockFactory() | ||
{ | ||
$factory = $this->getMockBuilder(Factory::class) | ||
->setMethods(['synopsize']) | ||
->getMock(); | ||
|
||
$factory->expects($this->exactly(2)) | ||
->method('synopsize') | ||
->withConsecutive(['b'], ['d']) | ||
->willReturnOnConsecutiveCalls(1, 2); | ||
|
||
return $factory; | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace TheIconic\Synopsis; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Exception; | ||
use TheIconic\Synopsis\AbstractSynopsis; | ||
use TheIconic\Synopsis\ArraySynopsis; | ||
use TheIconic\Synopsis\Factory; | ||
use TheIconic\Synopsis\StringSynopsis; | ||
|
||
class BooleanSynopsisTest extends TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testProcess() | ||
{ | ||
$synopsis = new BooleanSynopsis(); | ||
$synopsis->process(true, 3); | ||
|
||
$this->assertEquals('boolean', $synopsis->getType()); | ||
$this->assertEquals(1, $synopsis->getLength()); | ||
$this->assertEquals('true', $synopsis->getValue()); | ||
$this->assertFalse($synopsis->hasChildren()); | ||
$this->assertNull($synopsis->getChildren()); | ||
} | ||
} |
Oops, something went wrong.