DisconnectedMetadataFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
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\Mapping\ClassMetadataInfo;
9
10
class DisconnectedMetadataFactoryTest extends TestCase
11
{
12
    /**
13
     * @expectedException \RuntimeException
14
     * @expectedExceptionMessage Can't find base path for "Doctrine\Bundle\DoctrineBundle\Tests\Mapping\DisconnectedMetadataFactoryTest
15
     */
16
    public function testCannotFindNamespaceAndPathForMetadata() : void
17
    {
18
        $class      = new ClassMetadataInfo(self::class);
19
        $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...
20
21
        $registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock();
22
        $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...
23
24
        $factory->findNamespaceAndPathForMetadata($collection);
25
    }
26
27
    public function testFindNamespaceAndPathForMetadata() : void
28
    {
29
        $class      = new ClassMetadataInfo('\Vendor\Package\Class');
30
        $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...
31
32
        $registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock();
33
        $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...
34
35
        $factory->findNamespaceAndPathForMetadata($collection, '/path/to/code');
36
37
        $this->assertEquals('\Vendor\Package', $collection->getNamespace());
38
    }
39
}
40