These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace DoctrineModuleTest\ServiceFactory; |
||
6 | |||
7 | use DoctrineModuleTest\ServiceManagerFactory; |
||
8 | use Laminas\ServiceManager\ServiceLocatorInterface; |
||
9 | use PHPUnit\Framework\TestCase; |
||
10 | |||
11 | /** |
||
12 | * Test that verifies that services are defined correctly |
||
13 | * |
||
14 | * @link http://www.doctrine-project.org/ |
||
15 | */ |
||
16 | class ModuleDefinedServicesTest extends TestCase |
||
17 | { |
||
18 | /** @var ServiceLocatorInterface */ |
||
19 | protected $serviceManager; |
||
20 | |||
21 | protected function setUp() : void |
||
22 | { |
||
23 | $this->serviceManager = ServiceManagerFactory::getServiceManager(); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Verifies that the module defines the correct services |
||
28 | * |
||
29 | * @dataProvider getServicesThatShouldBeDefined |
||
30 | */ |
||
31 | public function testModuleDefinedServices(string $serviceName, bool $defined) : void |
||
32 | { |
||
33 | $this->assertSame($defined, $this->serviceManager->has($serviceName)); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Verifies that the module defines the correct services |
||
38 | * |
||
39 | * @dataProvider getServicesThatCanBeFetched |
||
40 | */ |
||
41 | public function testModuleFetchedService(string $serviceName, string $expectedClass) : void |
||
42 | { |
||
43 | $this->assertInstanceOf($expectedClass, $this->serviceManager->get($serviceName)); |
||
0 ignored issues
–
show
The method
assertInstanceOf() does not seem to exist on object<DoctrineModuleTes...uleDefinedServicesTest> .
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 | } |
||
45 | |||
46 | /** |
||
47 | * Verifies that the module defines the correct services |
||
48 | * |
||
49 | * @dataProvider getServicesThatCannotBeFetched |
||
50 | */ |
||
51 | public function testModuleInvalidService(string $serviceName) : void |
||
52 | { |
||
53 | $this->expectException('Laminas\ServiceManager\Exception\ServiceNotFoundException'); |
||
0 ignored issues
–
show
The method
expectException() does not seem to exist on object<DoctrineModuleTes...uleDefinedServicesTest> .
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...
|
|||
54 | |||
55 | $this->serviceManager->get($serviceName); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return mixed[][] |
||
60 | */ |
||
61 | public function getServicesThatShouldBeDefined() : array |
||
62 | { |
||
63 | return [ |
||
64 | ['doctrine.cache.array', true], |
||
65 | ['doctrine.cache.apc', true], |
||
66 | ['doctrine.cache.filesystem', true], |
||
67 | ['doctrine.cache.memcache', true], |
||
68 | ['doctrine.cache.memcached', true], |
||
69 | ['doctrine.cache.redis', true], |
||
70 | ['doctrine.cache.wincache', true], |
||
71 | ['doctrine.cache.xcache', true], |
||
72 | ['doctrine.cache.zenddata', true], |
||
73 | ['doctrine.authenticationadapter.orm_default', true], |
||
74 | ['doctrine.authenticationstorage.orm_default', true], |
||
75 | ['doctrine.authenticationservice.orm_default', true], |
||
76 | ['doctrine.authenticationadapter.odm_default', true], |
||
77 | ['doctrine.authenticationstorage.odm_default', true], |
||
78 | ['doctrine.authenticationservice.odm_default', true], |
||
79 | ['foo', false], |
||
80 | ['foo.bar', false], |
||
81 | ['foo.bar.baz', false], |
||
82 | ['doctrine', false], |
||
83 | ['doctrine.foo', false], |
||
84 | ['doctrine.foo.bar', false], |
||
85 | ['doctrine.cache.bar', false], |
||
86 | //['doctrine.cache.laminascachestorage'], |
||
87 | ]; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return string[][] |
||
92 | */ |
||
93 | public function getServicesThatCanBeFetched() : array |
||
94 | { |
||
95 | return [ |
||
96 | ['doctrine.cache.array', 'Doctrine\Common\Cache\ArrayCache'], |
||
97 | ]; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @return string[][] |
||
102 | */ |
||
103 | public function getServicesThatCannotBeFetched() : array |
||
104 | { |
||
105 | return [ |
||
106 | ['foo'], |
||
107 | ['foo.bar'], |
||
108 | ['foo.bar.baz'], |
||
109 | ['doctrine'], |
||
110 | ['doctrine.foo'], |
||
111 | ['doctrine.foo.bar'], |
||
112 | ['doctrine.cache.bar'], |
||
113 | ]; |
||
114 | } |
||
115 | } |
||
116 |
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.