Completed
Push — master ( 797b83...0467ef )
by
unknown
09:48 queued 04:48
created

ServiceEntityRepositoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 12
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testConstructorThrowsExceptionWhenNoManagerFound() 0 5 1
1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\Tests\Repository;
4
5
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
6
use Doctrine\Common\Persistence\ManagerRegistry;
7
use PHPUnit\Framework\TestCase;
8
9
class ServiceEntityRepositoryTest extends TestCase
10
{
11
    /**
12
     * @expectedException \LogicException
13
     * @expectedExceptionMessage Could not find the entity manager for class "Doctrine\Bundle\DoctrineBundle\Tests\Repository\TestEntity". Check your Doctrine configuration to make sure it is configured to load this entity’s metadata.
14
     */
15
    public function testConstructorThrowsExceptionWhenNoManagerFound()
16
    {
17
        $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
18
        new ServiceEntityRepository($registry, TestEntity::class);
0 ignored issues
show
Documentation introduced by
$registry is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\Common\P...stence\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...
19
    }
20
}
21