These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Doctrine\Tests\ORM\Tools; |
||
4 | |||
5 | use Doctrine\Common\Cache\ArrayCache; |
||
6 | use Doctrine\Common\Cache\Cache; |
||
7 | use Doctrine\ORM\Configuration; |
||
8 | use Doctrine\ORM\Mapping\Driver\AnnotationDriver; |
||
9 | use Doctrine\ORM\Mapping\Driver\XmlDriver; |
||
10 | use Doctrine\ORM\Mapping\Driver\YamlDriver; |
||
11 | use Doctrine\ORM\Tools\Setup; |
||
12 | use Doctrine\ORM\Version; |
||
13 | use Doctrine\Tests\OrmTestCase; |
||
14 | |||
15 | class SetupTest extends OrmTestCase |
||
16 | { |
||
17 | private $originalAutoloaderCount; |
||
18 | private $originalIncludePath; |
||
19 | |||
20 | public function setUp() |
||
21 | { |
||
22 | if (strpos(Version::VERSION, "DEV") === false) { |
||
23 | $this->markTestSkipped("Test only runs in a dev-installation from Github"); |
||
24 | } |
||
25 | |||
26 | $this->originalAutoloaderCount = count(spl_autoload_functions()); |
||
27 | $this->originalIncludePath = get_include_path(); |
||
28 | } |
||
29 | |||
30 | public function tearDown() |
||
31 | { |
||
32 | if ( ! $this->originalIncludePath) { |
||
33 | return; |
||
34 | } |
||
35 | |||
36 | set_include_path($this->originalIncludePath); |
||
37 | $loaders = spl_autoload_functions(); |
||
38 | $numberOfLoaders = count($loaders); |
||
39 | for ($i = 0; $i < $numberOfLoaders; $i++) { |
||
40 | if ($i > $this->originalAutoloaderCount+1) { |
||
41 | spl_autoload_unregister($loaders[$i]); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | public function testDirectoryAutoload() |
||
47 | { |
||
48 | Setup::registerAutoloadDirectory(__DIR__ . "/../../../../../vendor/doctrine/common/lib"); |
||
49 | |||
50 | $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); |
||
51 | } |
||
52 | |||
53 | public function testAnnotationConfiguration() |
||
54 | { |
||
55 | $config = Setup::createAnnotationMetadataConfiguration([], true); |
||
56 | |||
57 | $this->assertInstanceOf(Configuration::class, $config); |
||
58 | $this->assertEquals(sys_get_temp_dir(), $config->getProxyDir()); |
||
59 | $this->assertEquals('DoctrineProxies', $config->getProxyNamespace()); |
||
60 | $this->assertInstanceOf(AnnotationDriver::class, $config->getMetadataDriverImpl()); |
||
61 | } |
||
62 | |||
63 | public function testXMLConfiguration() |
||
64 | { |
||
65 | $config = Setup::createXMLMetadataConfiguration([], true); |
||
66 | |||
67 | $this->assertInstanceOf(Configuration::class, $config); |
||
68 | $this->assertInstanceOf(XmlDriver::class, $config->getMetadataDriverImpl()); |
||
69 | } |
||
70 | |||
71 | public function testYAMLConfiguration() |
||
72 | { |
||
73 | $config = Setup::createYAMLMetadataConfiguration([], true); |
||
74 | |||
75 | $this->assertInstanceOf(Configuration::class, $config); |
||
76 | $this->assertInstanceOf(YamlDriver::class, $config->getMetadataDriverImpl()); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @group DDC-1350 |
||
81 | */ |
||
82 | public function testConfigureProxyDir() |
||
83 | { |
||
84 | $config = Setup::createAnnotationMetadataConfiguration([], true, "/foo"); |
||
85 | $this->assertEquals('/foo', $config->getProxyDir()); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @group DDC-1350 |
||
90 | */ |
||
91 | View Code Duplication | public function testConfigureCache() |
|
92 | { |
||
93 | $cache = new ArrayCache(); |
||
94 | $config = Setup::createAnnotationMetadataConfiguration([], true, null, $cache); |
||
95 | |||
96 | $this->assertSame($cache, $config->getResultCacheImpl()); |
||
97 | $this->assertSame($cache, $config->getMetadataCacheImpl()); |
||
98 | $this->assertSame($cache, $config->getQueryCacheImpl()); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @group DDC-3190 |
||
103 | */ |
||
104 | View Code Duplication | public function testConfigureCacheCustomInstance() |
|
105 | { |
||
106 | $cache = $this->createMock(Cache::class); |
||
107 | $config = Setup::createConfiguration([], true, $cache); |
||
0 ignored issues
–
show
true is of type boolean , but the function expects a string|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
108 | |||
109 | $this->assertSame($cache, $config->getResultCacheImpl()); |
||
110 | $this->assertSame($cache, $config->getMetadataCacheImpl()); |
||
111 | $this->assertSame($cache, $config->getQueryCacheImpl()); |
||
112 | } |
||
113 | } |
||
114 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: