MigrationEventTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Tests\Unit\Event;
4
5
use RDV\Bundle\MigrationBundle\Event\MigrationEvent;
6
7
class MigrationEventTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var MigrationEvent
11
     */
12
    protected $migrationEvent;
13
14
    /** @var \PHPUnit_Framework_MockObject_MockObject */
15
    protected $connection;
16
17
    protected function setUp()
18
    {
19
        $this->connection = $this->getMockBuilder('Doctrine\DBAL\Connection')
20
            ->disableOriginalConstructor()
21
            ->getMock();
22
        $this->migrationEvent = new MigrationEvent($this->connection);
23
    }
24
25
    public function testMigrationData()
26
    {
27
        $middleMigration = $this->getMockForAbstractClass('RDV\Bundle\MigrationBundle\Migration\Migration');
28
        $this->migrationEvent->addMigration($middleMigration);
29
        $firstMigration = $this->getMockForAbstractClass('RDV\Bundle\MigrationBundle\Migration\Migration');
30
        $this->migrationEvent->addMigration($firstMigration, true);
31
        $lastMigration = $this->getMockForAbstractClass('RDV\Bundle\MigrationBundle\Migration\Migration');
32
        $this->migrationEvent->addMigration($lastMigration);
33
34
        $migrations = $this->migrationEvent->getMigrations();
35
        $this->assertEquals(3, count($migrations));
36
        $this->assertEquals($firstMigration, $migrations[0]);
37
        $this->assertEquals($middleMigration, $migrations[1]);
38
        $this->assertEquals($lastMigration, $migrations[2]);
39
    }
40
41
    public function testGetData()
42
    {
43
        $sql = 'select * from test_table';
44
        $params = [];
45
        $types = [];
46
47
        $this->connection->expects($this->once())
48
            ->method('fetchAll')
49
            ->with($sql, $params, $types)
50
            ->will($this->returnValue([]));
51
        $this->migrationEvent->getData($sql, $params, $types);
52
    }
53
}
54