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\Service; |
||
6 | |||
7 | use DoctrineModule\Service\DriverFactory; |
||
8 | use Laminas\ServiceManager\ServiceManager; |
||
9 | use PHPUnit\Framework\TestCase as BaseTestCase; |
||
10 | |||
11 | /** |
||
12 | * Base test case to be used when a service manager instance is required |
||
13 | */ |
||
14 | class DriverFactoryTest extends BaseTestCase |
||
15 | { |
||
16 | public function testCreateDriver() : void |
||
17 | { |
||
18 | $serviceManager = new ServiceManager(); |
||
19 | $serviceManager->setService( |
||
20 | 'config', |
||
21 | [ |
||
22 | 'doctrine' => [ |
||
23 | 'driver' => [ |
||
24 | 'testDriver' => ['class' => 'DoctrineModuleTest\Service\Mock\MetadataDriverMock'], |
||
25 | ], |
||
26 | ], |
||
27 | ] |
||
28 | ); |
||
29 | |||
30 | $factory = new DriverFactory('testDriver'); |
||
31 | $driver = $factory->createService($serviceManager); |
||
32 | $this->assertInstanceOf('DoctrineModuleTest\Service\Mock\MetadataDriverMock', $driver); |
||
0 ignored issues
–
show
|
|||
33 | } |
||
34 | |||
35 | public function testCreateDriverChain() : void |
||
36 | { |
||
37 | $serviceManager = new ServiceManager(); |
||
38 | $serviceManager->setService( |
||
39 | 'config', |
||
40 | [ |
||
41 | 'doctrine' => [ |
||
42 | 'driver' => [ |
||
43 | 'testDriver' => ['class' => 'DoctrineModuleTest\Service\Mock\MetadataDriverMock'], |
||
44 | 'testChainDriver' => [ |
||
45 | 'class' => 'Doctrine\Persistence\Mapping\Driver\MappingDriverChain', |
||
46 | 'drivers' => [ |
||
47 | 'Foo\Bar' => 'testDriver', |
||
48 | 'Foo\Baz' => null, |
||
49 | ], |
||
50 | ], |
||
51 | ], |
||
52 | ], |
||
53 | ] |
||
54 | ); |
||
55 | |||
56 | $factory = new DriverFactory('testChainDriver'); |
||
57 | $driver = $factory->createService($serviceManager); |
||
58 | $this->assertInstanceOf('Doctrine\Persistence\Mapping\Driver\MappingDriverChain', $driver); |
||
0 ignored issues
–
show
The method
assertInstanceOf() does not seem to exist on object<DoctrineModuleTes...vice\DriverFactoryTest> .
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...
|
|||
59 | $drivers = $driver->getDrivers(); |
||
60 | $this->assertCount(1, $drivers); |
||
0 ignored issues
–
show
The method
assertCount() does not seem to exist on object<DoctrineModuleTes...vice\DriverFactoryTest> .
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...
|
|||
61 | $this->assertArrayHasKey('Foo\Bar', $drivers); |
||
0 ignored issues
–
show
The method
assertArrayHasKey() does not seem to exist on object<DoctrineModuleTes...vice\DriverFactoryTest> .
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...
|
|||
62 | $this->assertInstanceOf('DoctrineModuleTest\Service\Mock\MetadataDriverMock', $drivers['Foo\Bar']); |
||
0 ignored issues
–
show
The method
assertInstanceOf() does not seem to exist on object<DoctrineModuleTes...vice\DriverFactoryTest> .
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...
|
|||
63 | } |
||
64 | } |
||
65 |
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.