-
Notifications
You must be signed in to change notification settings - Fork 1
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
Marc Aschmann
committed
Jun 12, 2016
1 parent
3eeff80
commit ecd9d3b
Showing
7 changed files
with
149 additions
and
41 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,66 @@ | ||
<?php | ||
/* | ||
* This file is part of the asm/phpflo-bundle package. | ||
* | ||
* (c) Marc Aschmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\Flow; | ||
|
||
|
||
use Asm\PhpFloBundle\Flow\ComponentRegistry; | ||
use PhpFlo\ComponentInterface; | ||
|
||
/** | ||
* Class ComponentRegistryTest | ||
* | ||
* @package Tests\Flow | ||
* @author Marc Aschmann <[email protected]> | ||
*/ | ||
class ComponentRegistryTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testGetReference() | ||
{ | ||
$componentMock = $this->createMock('\PhpFlo\ComponentInterface'); | ||
$registry = $this->createRegistry(); | ||
$registry->addReference($componentMock, 'component_1'); | ||
|
||
$component = $registry->getReference('component_1'); | ||
$this->assertInstanceOf('\PhpFlo\ComponentInterface', $component, 'addReference failed'); | ||
} | ||
|
||
public function testGetReferences() | ||
{ | ||
$componentMock = $this->createMock('\PhpFlo\ComponentInterface'); | ||
$registry = $this->createRegistry(); | ||
$registry | ||
->addReference($componentMock, 'component_1') | ||
->addReference($componentMock, 'component_2'); | ||
|
||
$references = $registry->getReferences(); | ||
|
||
$this->assertTrue(is_array($references)); | ||
$this->assertArrayHasKey('component_1', $references, 'registry key for component_1 not found'); | ||
$this->assertArrayHasKey('component_2', $references, 'registry key for component_2 not found'); | ||
} | ||
|
||
public function testRemoveReference() | ||
{ | ||
$componentMock = $this->createMock('\PhpFlo\ComponentInterface'); | ||
$registry = $this->createRegistry(); | ||
$registry->addReference($componentMock, 'component_1'); | ||
$component = $registry->getReference('component_1'); | ||
$this->assertInstanceOf('\PhpFlo\ComponentInterface', $component, 'addReference failed'); | ||
$registry->removeReference('component_1'); | ||
$result = $registry->getReference('component_1'); | ||
$this->assertFalse($result, 'reference was not removed'); | ||
} | ||
|
||
private function createRegistry() | ||
{ | ||
return new ComponentRegistry(); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
/* | ||
* This file is part of the asm/phpflo-bundle package. | ||
* | ||
* (c) Marc Aschmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\Flow; | ||
|
||
use Asm\PhpFloBundle\Flow\Network; | ||
use PhpFlo\Graph; | ||
|
||
/** | ||
* Class NetworkTest | ||
* | ||
* @package Tests\Flow | ||
* @author Marc Aschmann <[email protected]> | ||
*/ | ||
class NetworkTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testCreate() | ||
{ | ||
// no interface for mocking available, constructor needs argument | ||
$graph = new Graph('test');//$this->getMockBuilder('\PhpFlo\Graph')->getMock(); | ||
$registry = $this->getMockBuilder('\Asm\PhpFloBundle\Common\RegistryInterface')->getMock(); | ||
|
||
$network = Network::create($graph, $registry); | ||
|
||
$this->assertInstanceOf('\Asm\PhpFloBundle\Flow\Network', $network); | ||
} | ||
|
||
private function createNetwork() | ||
{ | ||
$graph = $graph = new Graph('test'); | ||
$registry = $this->getMockBuilder('\Asm\PhpFloBundle\Common\RegistryInterface')->getMock(); | ||
|
||
$network = new Network($graph, $registry); | ||
} | ||
} |
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,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="./vendor/autoload.php" | ||
> | ||
<php> | ||
<server name="KERNEL_DIR" value="Tests/App" /> | ||
</php> | ||
<testsuites> | ||
<testsuite name="PhpFloBundle testsuite"> | ||
<directory suffix="Test.php">./Tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./</directory> | ||
<exclude> | ||
<directory>./Common</directory> | ||
<directory>./DependencyInjection</directory> | ||
<directory>./Resources</directory> | ||
<directory>./Tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |