SchemaValidityFunctionalTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A theSchemaShouldBeValid() 0 5 1
A tearDown() 0 5 1
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