theSchemaShouldBeValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace BCRM\BackendBundle\Tests;
4
5
use Doctrine\Common\Persistence\ManagerRegistry;
6
use Doctrine\ORM\Tools\SchemaValidator;
7
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
8
9
/**
10
 * Tests the validity of the schema.
11
 */
12
class SchemaValidityFunctionalTest extends WebTestCase
13
{
14
15
    /**
16
     * @var \Doctrine\Common\Persistence\ObjectManager
17
     */
18
    private $em;
19
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function setUp()
24
    {
25
        static::$kernel = static::createKernel();
26
        static::$kernel->boot();
27
        /** @var ManagerRegistry $doctrine */
28
        $doctrine = static::$kernel->getContainer()
29
            ->get('doctrine');
30
        $this->em = $doctrine->getManager();
31
    }
32
33
    /**
34
     * @test
35
     */
36
    public function theSchemaShouldBeValid()
37
    {
38
        $validator = new SchemaValidator($this->em);
0 ignored issues
show
Compatibility introduced by
$this->em of type object<Doctrine\Common\Persistence\ObjectManager> is not a sub-type of object<Doctrine\ORM\EntityManagerInterface>. It seems like you assume a child interface of the interface Doctrine\Common\Persistence\ObjectManager to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
39
        $this->assertSame(array(), $validator->validateMapping(), 'Schema has valid mappings');
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45
    protected function tearDown()
46
    {
47
        parent::tearDown();
48
        $this->em->clear();
49
    }
50
}
51