Completed
Push — master ( e0017c...6b1304 )
by Tom
14s queued 11s
created

UniqueObjectFactoryTest::testInvoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Validator\Service;
6
7
use Doctrine\Persistence\ObjectManager;
8
use Doctrine\Persistence\ObjectRepository;
9
use DoctrineModule\Validator\UniqueObject;
10
use Interop\Container\ContainerInterface;
11
use PHPUnit\Framework\TestCase;
12
13
/**
14
 * Generated by PHPUnit_SkeletonGenerator on 2017-09-04 at 11:57:37.
15
 *
16
 * @coversDefaultClass DoctrineModule\Validator\Service\UniqueObjectFactory
17
 * @group validator
18
 */
19
class UniqueObjectFactoryTest extends TestCase
20
{
21
    /** @var UniqueObjectFactory */
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() : void
29
    {
30
        $this->object = new UniqueObjectFactory();
31
    }
32
33
    /**
34
     * @covers ::__invoke
35
     */
36
    public function testInvoke() : void
37
    {
38
        $options = [
39
            'target_class' => 'Foo\Bar',
40
            'fields'       => ['test'],
41
        ];
42
43
        $repository    = $this->prophesize(ObjectRepository::class);
0 ignored issues
show
Bug introduced by
The method prophesize() does not seem to exist on object<DoctrineModule\Va...niqueObjectFactoryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        $objectManager = $this->prophesize(ObjectManager::class);
0 ignored issues
show
Bug introduced by
The method prophesize() does not seem to exist on object<DoctrineModule\Va...niqueObjectFactoryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $objectManager->getRepository('Foo\Bar')
46
            ->shouldBeCalled()
47
            ->willReturn($repository->reveal());
48
49
        $container = $this->prophesize(ContainerInterface::class);
0 ignored issues
show
Bug introduced by
The method prophesize() does not seem to exist on object<DoctrineModule\Va...niqueObjectFactoryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<DoctrineModule\Va...niqueObjectFactoryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
    }
61
}
62