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