Completed
Push — master ( 126914...10d409 )
by
unknown
02:45
created

MigrateAllCommandTest::testGetMigrations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace ReddogsTest\Doctrine\Migrations;
4
5
use Reddogs\Doctrine\Migrations\MigrateAllCommand;
6
use Zend\Console\Adapter\AdapterInterface;
7
use ZF\Console\Route;
8
9
class MigrateAllCommandTest extends \PHPUnit_Framework_TestCase
10
{
11
    private $configurations, $migrations, $configuration, $migration;
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...
12
13
    protected function setUp()
14
    {
15
        $this->configuration = $this->getMockBuilder(Configuration::class)
16
            ->disableOriginalConstructor()
17
            ->setMethods(['createMigrationTable'])
18
            ->getMock();;
19
        $this->configurations = ['testKey' => $this->configuration];
20
21
        $this->migration = $this->getMockBuilder(Migration::class)
22
            ->disableOriginalConstructor()
23
            ->setMethods(['migrate'])
24
            ->getMock();
25
        $this->migrations = ['testKey' => $this->migration];
26
27
        $this->command = new MigrateAllCommand($this->configurations, $this->migrations);
0 ignored issues
show
Bug introduced by
The property command does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
    }
29
30
    public function testGetConfigurations()
31
    {
32
        $this->assertSame($this->configurations, $this->command->getConfigurations());
33
    }
34
35
    public function testGetMigrations()
36
    {
37
        $this->assertSame($this->migrations, $this->command->getMigrations());
38
    }
39
40
    public function testInvoke()
41
    {
42
        $this->configuration->expects($this->once())
43
            ->method('createMigrationTable');
44
45
        $this->migration->expects($this->once())
46
            ->method('migrate');
47
48
        $route = new Route('mogrations:migrate-all', 'mogrations:migrate-all <moduleName>');
49
        $adapter = $this->createMock(AdapterInterface::class);
50
        $this->command->__invoke($route, $adapter);
51
    }
52
}