Completed
Push — master ( 8fb423...c81d0e )
by
unknown
04:06
created

MigrateAllCommandTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 50
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 14 1
A testGetMigrateCommand() 0 4 1
A testGetMigrationsConfig() 0 4 1
A testInvoke() 0 20 1
1
<?php
2
3
namespace ReddogsTest\Doctrine\Migrations;
4
5
use Reddogs\Doctrine\Migrations\MigrateCommand;
6
use Reddogs\Doctrine\Migrations\MigrateAllCommand;
7
use Zend\Console\Adapter\AdapterInterface;
8
use ZF\Console\Route;
9
10
class MigrateAllCommandTest extends \PHPUnit_Framework_TestCase
11
{
12
    private $command, $migrateCommand, $migrationsConfig;
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
13
14
    protected function setUp()
15
    {
16
        $this->migrateCommand = $this->getMockBuilder(MigrateCommand::class)
17
            ->disableOriginalConstructor()
18
            ->setMethods(['__invoke'])
19
            ->getMock();
20
21
        $this->migrationsConfig = [
22
            'testKey1' => [],
23
            'testKey2' => [],
24
        ];
25
26
        $this->command = new MigrateAllCommand($this->migrateCommand, $this->migrationsConfig);
27
    }
28
29
    public function testGetMigrateCommand()
30
    {
31
        $this->assertSame($this->migrateCommand, $this->command->getMigrateCommand());
32
    }
33
34
    public function testGetMigrationsConfig()
35
    {
36
        $this->assertSame($this->migrationsConfig, $this->command->getMigrationsConfig());
37
    }
38
39
    public function testInvoke()
40
    {
41
        $route = new Route('mogrations:migrate-all', 'mogrations:migrate-all');
42
        $console = $this->createMock(AdapterInterface::class);
43
44
        $migrateRoute1 = new Route('migrations:migrate', 'migrations:migrate testKey1');
45
        $migrateRoute2 = new Route('migrations:migrate', 'migrations:migrate testKey2');
46
47
        $this->migrateCommand->expects($this->at(0))
48
            ->method('__invoke')
49
            ->with($this->equalTo($migrateRoute1),
50
                   $this->equalTo($console));
51
52
        $this->migrateCommand->expects($this->at(1))
53
            ->method('__invoke')
54
            ->with($this->equalTo($migrateRoute2),
55
                   $this->equalTo($console));
56
57
        $this->command->__invoke($route, $console);
58
    }
59
}