1 | <?php |
||
23 | class NoObjectExistsFactoryTest extends TestCase |
||
24 | { |
||
25 | /** @var NoObjectExistsFactory */ |
||
26 | private $object; |
||
27 | |||
28 | /** |
||
29 | * Sets up the fixture, for example, opens a network connection. |
||
30 | * This method is called before a test is executed. |
||
31 | */ |
||
32 | protected function setUp() : void |
||
33 | { |
||
34 | $this->object = new NoObjectExistsFactory(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @coversNothing |
||
39 | */ |
||
40 | public function testCallable() : void |
||
41 | { |
||
42 | $this->assertIsCallable($this->object); |
||
|
|||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @covers ::__invoke |
||
47 | * @covers ::container |
||
48 | * @covers ::getRepository |
||
49 | * @covers ::getObjectManager |
||
50 | * @covers ::getFields |
||
51 | */ |
||
52 | public function testInvoke() : void |
||
53 | { |
||
54 | $options = [ |
||
55 | 'target_class' => 'Foo\Bar', |
||
56 | 'fields' => ['test'], |
||
57 | ]; |
||
58 | |||
59 | $repository = $this->prophesize(ObjectRepository::class); |
||
60 | $objectManager = $this->prophesize(ObjectManager::class); |
||
61 | $objectManager->getRepository('Foo\Bar') |
||
62 | ->shouldBeCalled() |
||
63 | ->willReturn($repository->reveal()); |
||
64 | |||
65 | $container = $this->prophesize(ContainerInterface::class); |
||
66 | $container->get('doctrine.entitymanager.orm_default') |
||
67 | ->shouldBeCalled() |
||
68 | ->willReturn($objectManager->reveal()); |
||
69 | |||
70 | $instance = $this->object->__invoke( |
||
71 | $container->reveal(), |
||
72 | NoObjectExists::class, |
||
73 | $options |
||
74 | ); |
||
75 | $this->assertInstanceOf(NoObjectExists::class, $instance); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @covers ::__invoke |
||
80 | * @covers ::container |
||
81 | * @covers ::getRepository |
||
82 | * @covers ::getObjectManager |
||
83 | * @covers ::getFields |
||
84 | */ |
||
85 | public function testInvokeWithObjectManagerGiven() : void |
||
86 | { |
||
87 | $repository = $this->prophesize(ObjectRepository::class); |
||
88 | $objectManager = $this->prophesize(ObjectManager::class); |
||
89 | $objectManager->getRepository('Foo\Bar') |
||
90 | ->shouldBeCalled() |
||
91 | ->willReturn($repository->reveal()); |
||
92 | |||
93 | $options = [ |
||
94 | 'target_class' => 'Foo\Bar', |
||
95 | 'object_manager' => $objectManager->reveal(), |
||
96 | 'fields' => ['test'], |
||
97 | ]; |
||
98 | |||
99 | $container = $this->prophesize(ContainerInterface::class); |
||
100 | $container->get('doctrine.entitymanager.orm_default') |
||
101 | ->shouldNotBeCalled(); |
||
102 | |||
103 | $instance = $this->object->__invoke( |
||
104 | $container->reveal(), |
||
105 | NoObjectExists::class, |
||
106 | $options |
||
107 | ); |
||
108 | $this->assertInstanceOf(NoObjectExists::class, $instance); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * @covers ::merge |
||
113 | */ |
||
114 | public function testInvokeWithMerge() : void |
||
115 | { |
||
116 | $options = [ |
||
117 | 'target_class' => 'Foo\Bar', |
||
118 | 'fields' => ['test'], |
||
119 | 'messages' => [NoObjectExists::ERROR_OBJECT_FOUND => 'test'], |
||
120 | ]; |
||
121 | |||
122 | $repository = $this->prophesize(ObjectRepository::class); |
||
123 | $objectManager = $this->prophesize(ObjectManager::class); |
||
124 | $objectManager->getRepository('Foo\Bar') |
||
125 | ->shouldBeCalled() |
||
126 | ->willReturn($repository->reveal()); |
||
127 | |||
128 | $container = $this->prophesize(ContainerInterface::class); |
||
129 | $container->get('doctrine.entitymanager.orm_default') |
||
130 | ->shouldBeCalled() |
||
131 | ->willReturn($objectManager->reveal()); |
||
132 | |||
133 | $instance = $this->object->__invoke( |
||
134 | $container->reveal(), |
||
135 | NoObjectExists::class, |
||
136 | $options |
||
137 | ); |
||
138 | $templates = $instance->getMessageTemplates(); |
||
139 | $this->assertArrayHasKey(NoObjectExists::ERROR_OBJECT_FOUND, $templates); |
||
140 | $this->assertSame('test', $templates[NoObjectExists::ERROR_OBJECT_FOUND]); |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * @covers ::getRepository |
||
145 | */ |
||
146 | public function testInvokeWithoutTargetClass() : void |
||
157 | |||
158 | /** |
||
159 | * @covers ::createService |
||
160 | * @covers ::setCreationOptions |
||
161 | */ |
||
162 | public function testCreateService() : void |
||
184 | |||
185 | /** |
||
186 | * @covers ::container |
||
187 | */ |
||
188 | public function testCreateServiceWithServiceLocatorAwareInterface() : void |
||
220 | } |
||
221 |
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.