1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Abacaphiliac\DoctrineORMDiagnosticsModuleTest; |
4
|
|
|
|
5
|
|
|
use Abacaphiliac\DoctrineORMDiagnosticsModule\CheckCommand; |
6
|
|
|
use Abacaphiliac\DoctrineORMDiagnosticsModule\CheckMigrations\CheckMigrationsUpToDateFactory; |
7
|
|
|
use Doctrine\DBAL\Migrations\Configuration\Configuration; |
8
|
|
|
use Doctrine\DBAL\Migrations\Tools\Console\Command\UpToDateCommand; |
9
|
|
|
use DoctrineModule\ServiceFactory\AbstractDoctrineServiceFactory; |
10
|
|
|
use DoctrineORMModule\Service\MigrationsCommandFactory; |
11
|
|
|
use Zend\Console\Request; |
12
|
|
|
use Zend\ServiceManager\ServiceManager; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @covers \Abacaphiliac\DoctrineORMDiagnosticsModule\CheckMigrations\CheckMigrationsUpToDateFactory |
16
|
|
|
* @covers \Abacaphiliac\DoctrineORMDiagnosticsModule\AbstractCheckCommandFactory |
17
|
|
|
*/ |
18
|
|
|
class CheckMigrationsUpToDateFactoryTest extends \PHPUnit_Framework_TestCase |
19
|
|
|
{ |
20
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject|Configuration */ |
21
|
|
|
private $migrationsConfiguration; |
22
|
|
|
|
23
|
|
|
/** @var Request */ |
24
|
|
|
private $request; |
25
|
|
|
|
26
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject|UpToDateCommand */ |
27
|
|
|
private $command; |
28
|
|
|
|
29
|
|
|
/** @var ServiceManager */ |
30
|
|
|
private $serviceLocator; |
31
|
|
|
|
32
|
|
|
/** @var CheckMigrationsUpToDateFactory */ |
33
|
|
|
private $sut; |
34
|
|
|
|
35
|
|
|
protected function setUp() |
36
|
|
|
{ |
37
|
|
|
parent::setUp(); |
38
|
|
|
|
39
|
|
|
$this->serviceLocator = new ServiceManager(); |
40
|
|
|
$this->serviceLocator->addAbstractFactory(AbstractDoctrineServiceFactory::class); |
41
|
|
|
|
42
|
|
|
$this->command = $this->getMockBuilder(UpToDateCommand::class) |
43
|
|
|
->disableOriginalConstructor() |
44
|
|
|
->getMock(); |
45
|
|
|
|
46
|
|
|
$this->migrationsConfiguration = $this->getMockBuilder(Configuration::class) |
47
|
|
|
->disableOriginalConstructor() |
48
|
|
|
->getMock(); |
49
|
|
|
|
50
|
|
|
$this->request = new Request(); |
51
|
|
|
|
52
|
|
|
$this->sut = new CheckMigrationsUpToDateFactory(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testCreateService() |
56
|
|
|
{ |
57
|
|
|
$this->serviceLocator->setService('doctrine.migrations_cmd.uptodate', $this->command); |
58
|
|
|
$this->serviceLocator->setService('Request', $this->request); |
59
|
|
|
|
60
|
|
|
$actual = $this->sut->createService($this->serviceLocator); |
61
|
|
|
|
62
|
|
|
self::assertInstanceOf(CheckCommand::class, $actual); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testCreateServiceCollaborationTest() |
66
|
|
|
{ |
67
|
|
|
$this->serviceLocator->setService('config', [ |
68
|
|
|
'doctrine_factories' => [ |
69
|
|
|
'migrations_cmd' => MigrationsCommandFactory::class, |
70
|
|
|
], |
71
|
|
|
'doctrine' => [ |
72
|
|
|
'migrations_cmd' => [ |
73
|
|
|
'uptodate' => [], |
74
|
|
|
], |
75
|
|
|
], |
76
|
|
|
]); |
77
|
|
|
$this->serviceLocator->setService( |
78
|
|
|
'doctrine.migrations_configuration.orm_default', |
79
|
|
|
$this->migrationsConfiguration |
80
|
|
|
); |
81
|
|
|
$this->serviceLocator->setService('Request', $this->request); |
82
|
|
|
|
83
|
|
|
$actual = $this->sut->createService($this->serviceLocator); |
84
|
|
|
|
85
|
|
|
self::assertInstanceOf(CheckCommand::class, $actual); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|