Completed
Push — develop ( 7f6ad2...eb155e )
by Baptiste
02:38
created

RepositoryFactoryConfiguratorTest::testConfigure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 0
cts 31
cp 0
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 28
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Tests\Innmind\Neo4jBundle\Configurator;
5
6
use Innmind\Neo4jBundle\Configurator\RepositoryFactoryConfigurator;
7
use Innmind\Neo4j\ONM\{
8
    Metadata\ClassName,
9
    Metadata\Alias,
10
    Metadata\EntityInterface,
11
    Metadatas,
12
    RepositoryInterface,
13
    RepositoryFactory,
14
    UnitOfWork,
15
    Translation\MatchTranslator,
16
    Translation\SpecificationTranslator
17
};
18
19
class RepositoryFactoryConfiguratorTest extends \PHPUnit_Framework_TestCase
20
{
21
    public function testConfigure()
22
    {
23
        $entity = $this->getMock(EntityInterface::class);
24
        $entity
25
            ->method('class')
26
            ->willReturn(new ClassName('foo'));
27
        $entity
28
            ->method('alias')
29
            ->willReturn(new Alias('foo'));
30
        $m = new Metadatas;
31
        $m->register($entity);
32
        $c = new RepositoryFactoryConfigurator($m);
33
        $c->register('foo', $r = $this->getMock(RepositoryInterface::class));
34
        $f = new RepositoryFactory(
35
            $this
36
                ->getMockBuilder(UnitOfWork::class)
37
                ->disableOriginalConstructor()
38
                ->getMock(),
39
            $this
40
                ->getMockBuilder(MatchTranslator::class)
41
                ->disableOriginalConstructor()
42
                ->getMock(),
43
            $this
44
                ->getMockBuilder(SpecificationTranslator::class)
45
                ->disableOriginalConstructor()
46
                ->getMock()
47
        );
48
49
        $f2 = $c->configure($f);
50
51
        $this->assertSame($f, $f2);
52
        $this->assertSame($r, $f->make($entity));
53
    }
54
}
55