Skip to content

Commit ba6889f

Browse files
committed
Added tests for Either and Walk strategies.
1 parent 832f596 commit ba6889f

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
namespace ScriptFUSIONTest\Integration\Mapper\Strategy;
3+
4+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
5+
use Mockery\MockInterface;
6+
use ScriptFUSION\Mapper\Mapper;
7+
use ScriptFUSION\Mapper\Strategy\Either;
8+
use ScriptFUSION\Mapper\Strategy\Strategy;
9+
10+
final class EitherTest extends \PHPUnit_Framework_TestCase
11+
{
12+
use MockeryPHPUnitIntegration;
13+
14+
/** @var Either */
15+
private $either;
16+
17+
/** @var MockInterface */
18+
private $strategy;
19+
20+
protected function setUp()
21+
{
22+
$this->either = (new Either($this->strategy = \Mockery::spy(Strategy::class), 'bar'))->setMapper(new Mapper);
23+
}
24+
25+
public function testNonNullStrategy()
26+
{
27+
$either = $this->either;
28+
$this->strategy->shouldReceive('__invoke')->andReturn('foo');
29+
30+
self::assertSame('foo', $either([]));
31+
}
32+
33+
public function testNullStrategy()
34+
{
35+
$either = $this->either;
36+
37+
self::assertSame('bar', $either([]));
38+
}
39+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
namespace ScriptFUSIONTest\Unit\Mapper\Strategy;
3+
4+
use ScriptFUSION\Mapper\Strategy\Walk;
5+
use ScriptFUSIONTest\MockFactory;
6+
7+
final class WalkTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function test()
10+
{
11+
/** @var Walk $walk */
12+
$walk = (new Walk(null, 'foo->bar'))
13+
->setMapper(MockFactory::mockMapper(['foo' => ['bar' => 'baz']]))
14+
;
15+
16+
self::assertSame('baz', $walk([]));
17+
}
18+
}

0 commit comments

Comments
 (0)