-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starting unit test for visitor gateway
- Loading branch information
1 parent
bb9aed3
commit d26f212
Showing
2 changed files
with
74 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
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,71 @@ | ||
<?php | ||
|
||
/* | ||
* Mondrian | ||
*/ | ||
|
||
namespace Trismegiste\Mondrian\Tests\Visitor; | ||
|
||
use Trismegiste\Mondrian\Visitor\VisitorGateway; | ||
|
||
/** | ||
* VisitorGatewayTest tests the VisitorGateway | ||
*/ | ||
class VisitorGatewayTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
protected $sut; | ||
protected $reflectionCtx; | ||
protected $graphCtx; | ||
protected $graph; | ||
|
||
private function buildVisitor(array $visitor = []) | ||
{ | ||
$this->sut = new VisitorGateway($visitor, $this->reflectionCtx, $this->graphCtx, $this->graph); | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
$this->reflectionCtx = $this->getMock('Trismegiste\Mondrian\Transform\ReflectionContext'); | ||
$this->graphCtx = $this->getMockBuilder('Trismegiste\Mondrian\Transform\GraphContext') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->graph = $this->getMock('Trismegiste\Mondrian\Graph\Graph'); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testEmpty() | ||
{ | ||
$this->buildVisitor(); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
*/ | ||
public function testBadState() | ||
{ | ||
$this->buildVisitor(['sfd']); | ||
} | ||
|
||
public function testStateKey() | ||
{ | ||
$state0 = $this->getMock('Trismegiste\Mondrian\Visitor\State\State'); | ||
$state0->expects($this->exactly(2)) | ||
->method('getName') | ||
->will($this->returnValue('key0')); | ||
$state0->expects($this->once()) | ||
->method('setContext'); | ||
|
||
$state1 = $this->getMock('Trismegiste\Mondrian\Visitor\State\State'); | ||
$state1->expects($this->once()) | ||
->method('getName') | ||
->will($this->returnValue('key1')); | ||
$state1->expects($this->once()) | ||
->method('setContext'); | ||
|
||
$this->buildVisitor([$state0, $state1]); | ||
} | ||
|
||
} |