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; |
|
|
|
|
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
|
|
|
} |
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.