Skip to content

Commit 832f596

Browse files
committed
Added tests for Context, Merge and Unique strategies.
1 parent cf3d1bd commit 832f596

4 files changed

Lines changed: 63 additions & 1 deletion

File tree

test/Integration/Mapper/CollectionMapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function setUp()
1515
}
1616

1717
/**
18-
* Tests that when there is nothing to mapMapping an invalid Generator is returned.
18+
* Tests that when there is nothing to map an invalid Generator is returned.
1919
*/
2020
public function testMapNothing()
2121
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
namespace ScriptFUSIONTest\Integration\Mapper\Strategy;
3+
4+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
5+
use ScriptFUSION\Mapper\Mapper;
6+
use ScriptFUSION\Mapper\Strategy\Context;
7+
use ScriptFUSION\Mapper\Strategy\Strategy;
8+
9+
final class ContextTest extends \PHPUnit_Framework_TestCase
10+
{
11+
use MockeryPHPUnitIntegration;
12+
13+
public function test()
14+
{
15+
/** @var Context $context */
16+
$context = (new Context(
17+
\Mockery::mock(Strategy::class)
18+
->shouldReceive('__invoke')
19+
->with($data = [], $context = 'foo')
20+
->once()
21+
->getMock(),
22+
$context
23+
))->setMapper(new Mapper);
24+
25+
$context($data);
26+
}
27+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
namespace ScriptFUSIONTest\Unit\Mapper\Strategy;
3+
4+
use ScriptFUSION\Mapper\Mapper;
5+
use ScriptFUSION\Mapper\Strategy\Merge;
6+
7+
final class MergeTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function test()
10+
{
11+
/** @var Merge $merge */
12+
$merge = (new Merge('foo', 'bar'))->setMapper(new Mapper);
13+
14+
self::assertSame(['foo', 'bar'], $merge([]));
15+
}
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
namespace ScriptFUSIONTest\Unit\Mapper\Strategy;
3+
4+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
5+
use ScriptFUSION\Mapper\Strategy\Unique;
6+
use ScriptFUSIONTest\MockFactory;
7+
8+
final class UniqueTest extends \PHPUnit_Framework_TestCase
9+
{
10+
use MockeryPHPUnitIntegration;
11+
12+
public function test()
13+
{
14+
/** @var Unique $unique */
15+
$unique = (new Unique(null))->setMapper(MockFactory::mockMapper(['foo' => 'bar', 'baz' => 'bar']));
16+
17+
self::assertSame(['foo' => 'bar'], $unique([]));
18+
}
19+
}

0 commit comments

Comments
 (0)