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