SchemaDumperTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 79
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
B testDump() 0 28 1
A dumpDataProvider() 0 14 1
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Tests\Unit\Tools;
4
5
use Doctrine\DBAL\Schema\Schema;
6
use RDV\Bundle\MigrationBundle\Tools\SchemaDumper;
7
8
class SchemaDumperTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @var SchemaDumper
12
     */
13
    protected $schemaDumper;
14
15
    /**
16
     * @var Schema
17
     */
18
    protected $schema;
19
20
    /**
21
     * @var \PHPUnit_Framework_MockObject_MockObject
22
     */
23
    protected $twig;
24
25
    protected function setUp()
26
    {
27
        $this->twig = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock();
28
        $this->schema = new Schema();
29
        $this->schemaDumper = new SchemaDumper($this->twig);
30
31
        $this->schemaDumper->acceptSchema($this->schema);
32
    }
33
34
    /**
35
     * @dataProvider dumpDataProvider
36
     * @param array|null $allowedTables
37
     * @param string|null $namespace
38
     * @param string|null $expectedNamespace
39
     * @param string $className
40
     * @param string $version
41
     * @param array $extendedOptions
42
     */
43
    public function testDump(
44
        $allowedTables,
45
        $namespace,
46
        $expectedNamespace,
47
        $className,
48
        $version,
49
        $extendedOptions
50
    ) {
51
        $this->twig->expects($this->once())
52
            ->method('render')
53
            ->with(
54
                SchemaDumper::SCHEMA_TEMPLATE,
55
                [
56
                    'schema' => $this->schema,
57
                    'allowedTables' => $allowedTables,
58
                    'namespace' => $expectedNamespace,
59
                    'className' => $className,
60
                    'version' => $version,
61
                    'extendedOptions' => $extendedOptions
62
                ]
63
            )
64
            ->will($this->returnValue('TEST'));
65
66
        $this->assertEquals(
67
            'TEST',
68
            $this->schemaDumper->dump($allowedTables, $namespace, $className, $version, $extendedOptions)
69
        );
70
    }
71
72
    public function dumpDataProvider()
73
    {
74
        return array(
75
            array(null, null, null, null, null, null),
76
            array(
77
                array('test' => true),
78
                'Acme\DemoBundle\Entity',
79
                'Acme\DemoBundle',
80
                'DemoBundleInstaller',
81
                'v1_1',
82
                array('test' => array('id' => array('test' => true)))
83
            )
84
        );
85
    }
86
}
87