1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Bundle\DoctrineBundle\Tests\Mapping; |
4
|
|
|
|
5
|
|
|
use Doctrine\Bundle\DoctrineBundle\Mapping\ClassMetadataCollection; |
6
|
|
|
use Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory; |
7
|
|
|
use Doctrine\Bundle\DoctrineBundle\Tests\TestCase; |
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
9
|
|
|
use Doctrine\ORM\Mapping\ClassMetadataInfo; |
10
|
|
|
|
11
|
|
|
class DisconnectedMetadataFactoryTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
public static function setUpBeforeClass() : void |
14
|
|
|
{ |
15
|
|
|
if (interface_exists(EntityManagerInterface::class)) { |
16
|
|
|
return; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
self::markTestSkipped('This test requires ORM'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @expectedException \RuntimeException |
24
|
|
|
* @expectedExceptionMessage Can't find base path for "Doctrine\Bundle\DoctrineBundle\Tests\Mapping\DisconnectedMetadataFactoryTest |
25
|
|
|
*/ |
26
|
|
|
public function testCannotFindNamespaceAndPathForMetadata() : void |
27
|
|
|
{ |
28
|
|
|
$class = new ClassMetadataInfo(self::class); |
29
|
|
|
$collection = new ClassMetadataCollection([$class]); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock(); |
32
|
|
|
$factory = new DisconnectedMetadataFactory($registry); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$factory->findNamespaceAndPathForMetadata($collection); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testFindNamespaceAndPathForMetadata() : void |
38
|
|
|
{ |
39
|
|
|
$class = new ClassMetadataInfo('\Vendor\Package\Class'); |
40
|
|
|
$collection = new ClassMetadataCollection([$class]); |
|
|
|
|
41
|
|
|
|
42
|
|
|
$registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock(); |
43
|
|
|
$factory = new DisconnectedMetadataFactory($registry); |
|
|
|
|
44
|
|
|
|
45
|
|
|
$factory->findNamespaceAndPathForMetadata($collection, '/path/to/code'); |
46
|
|
|
|
47
|
|
|
$this->assertEquals('\Vendor\Package', $collection->getNamespace()); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
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: