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

ServiceEntityRepositoryTest::setUpBeforeClass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\Tests\Repository;
4
5
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
6
use Doctrine\ORM\EntityManagerInterface;
7
use Doctrine\Persistence\ManagerRegistry;
8
use PHPUnit\Framework\TestCase;
9
10
class ServiceEntityRepositoryTest extends TestCase
11
{
12
    public static function setUpBeforeClass() : void
13
    {
14
        if (interface_exists(EntityManagerInterface::class)) {
15
            return;
16
        }
17
18
        self::markTestSkipped('This test requires ORM');
19
    }
20
21
    /**
22
     * @expectedException \LogicException
23
     * @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.
24
     */
25
    public function testConstructorThrowsExceptionWhenNoManagerFound() : void
26
    {
27
        $registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
28
        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\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...
29
    }
30
}
31