AbstractTestMigrationExecutor::setUp()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 29
rs 8.8571
cc 1
eloc 24
nc 1
nop 0
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Tests\Unit\Migration;
4
5
use Doctrine\DBAL\Platforms\MySqlPlatform;
6
use RDV\Bundle\MigrationBundle\Migration\ArrayLogger;
7
use RDV\Bundle\MigrationBundle\Migration\MigrationQueryExecutor;
8
9
class AbstractTestMigrationExecutor extends \PHPUnit_Framework_TestCase
10
{
11
    /** @var \PHPUnit_Framework_MockObject_MockObject */
12
    protected $connection;
13
14
    /** @var ArrayLogger */
15
    protected $logger;
16
17
    /** @var MigrationQueryExecutor */
18
    protected $queryExecutor;
19
20
    protected function setUp()
21
    {
22
        $this->connection = $this->getMockBuilder('Doctrine\DBAL\Connection')
23
            ->disableOriginalConstructor()
24
            ->getMock();
25
26
        $platform = new MySqlPlatform();
27
        $sm       = $this->getMockBuilder('Doctrine\DBAL\Schema\AbstractSchemaManager')
28
            ->disableOriginalConstructor()
29
            ->setMethods(['listTables', 'createSchemaConfig'])
30
            ->getMockForAbstractClass();
31
        $sm->expects($this->once())
32
            ->method('listTables')
33
            ->will($this->returnValue($this->getTables()));
34
        $sm->expects($this->once())
35
            ->method('createSchemaConfig')
36
            ->will($this->returnValue(null));
37
        $this->connection->expects($this->atLeastOnce())
38
            ->method('getSchemaManager')
39
            ->will($this->returnValue($sm));
40
        $this->connection->expects($this->once())
41
            ->method('getDatabasePlatform')
42
            ->will($this->returnValue($platform));
43
44
        $this->logger = new ArrayLogger();
45
46
        $this->queryExecutor = new MigrationQueryExecutor($this->connection);
47
        $this->queryExecutor->setLogger($this->logger);
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    protected function getTables()
54
    {
55
        return [];
56
    }
57
}
58