Completed
Push — master ( 960666...619cc6 )
by Tom
14s
created

UniqueObjectFactoryTest::test__invoke()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
3
namespace DoctrineModule\Validator\Service;
4
5
use PHPUnit_Framework_TestCase as TestCase;
6
use DoctrineModule\Validator\UniqueObject;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Doctrine\Common\Persistence\ObjectRepository;
9
use Interop\Container\ContainerInterface;
10
11
/**
12
 * Generated by PHPUnit_SkeletonGenerator on 2017-09-04 at 11:57:37.
13
 *
14
 * @coversDefaultClass DoctrineModule\Validator\Service\UniqueObjectFactory
15
 * @group validator
16
 */
17
class UniqueObjectFactoryTest extends TestCase
18
{
19
    /**
20
     * @var UniqueObjectFactory
21
     */
22
    private $object;
23
24
    /**
25
     * Sets up the fixture, for example, opens a network connection.
26
     * This method is called before a test is executed.
27
     */
28
    protected function setUp()
29
    {
30
        $this->object = new UniqueObjectFactory;
31
    }
32
33
    /**
34
     * @covers ::__invoke
35
     */
36
    public function test__invoke()
0 ignored issues
show
Coding Style introduced by
Method name "UniqueObjectFactoryTest::test__invoke" is not in camel caps format
Loading history...
37
    {
38
        $options = [
39
            'target_class' => 'Foo\Bar',
40
            'fields'       => ['test'],
41
        ];
42
43
        $repository = $this->prophesize(ObjectRepository::class);
44
        $objectManager = $this->prophesize(ObjectManager::class);
45
        $objectManager->getRepository('Foo\Bar')
46
            ->shouldBeCalled()
47
            ->willReturn($repository->reveal());
48
49
        $container = $this->prophesize(ContainerInterface::class);
50
        $container->get('doctrine.entitymanager.orm_default')
51
            ->shouldBeCalled()
52
            ->willReturn($objectManager->reveal());
53
54
        $instance = $this->object->__invoke(
55
            $container->reveal(),
56
            UniqueObject::class,
57
            $options
58
        );
59
        $this->assertInstanceOf(UniqueObject::class, $instance);
60
    }
61
}
62