Completed
Pull Request — master (#1203)
by
unknown
04:38
created

DisconnectedMetadataFactoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpBeforeClass() 0 8 2
A testCannotFindNamespaceAndPathForMetadata() 0 10 1
A testFindNamespaceAndPathForMetadata() 0 12 1
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]);
0 ignored issues
show
Documentation introduced by
array($class) is of type array<integer,object<Doc...\\ClassMetadataInfo>"}>, but the function expects a array<integer,object<Doc...Mapping\ClassMetadata>>.

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...
30
31
        $registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock();
32
        $factory  = new DisconnectedMetadataFactory($registry);
0 ignored issues
show
Documentation introduced by
$registry is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\Persistence\ManagerRegistry>.

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...
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]);
0 ignored issues
show
Documentation introduced by
array($class) is of type array<integer,object<Doc...\\ClassMetadataInfo>"}>, but the function expects a array<integer,object<Doc...Mapping\ClassMetadata>>.

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...
41
42
        $registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock();
43
        $factory  = new DisconnectedMetadataFactory($registry);
0 ignored issues
show
Documentation introduced by
$registry is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\Persistence\ManagerRegistry>.

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...
44
45
        $factory->findNamespaceAndPathForMetadata($collection, '/path/to/code');
46
47
        $this->assertEquals('\Vendor\Package', $collection->getNamespace());
48
    }
49
}
50