/
DoctrineCommandTest.php
93 lines (73 loc) · 3.11 KB
/
DoctrineCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
declare(strict_types=1);
namespace Doctrine\Bundle\MigrationsBundle\Tests\Command;
use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand;
use Doctrine\Migrations\Configuration\Configuration;
use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
class DoctrineCommandTest extends TestCase
{
/** @var string */
private $migrationsDirectory;
protected function setUp() : void
{
vfsStream::setup('migrations_directory');
$this->migrationsDirectory = vfsStream::url('migrations_directory');
}
public function testConfigureMigrations() : void
{
/** @var Configuration|MockObject $configurationMock */
$configurationMock = $this->createMock(Configuration::class);
$configurationMock->method('getMigrations')
->willReturn([]);
$configurationMock->expects($this->once())
->method('setMigrationsDirectory')
->with($this->migrationsDirectory);
$configurationMock->expects($this->once())
->method('setMigrationsNamespace')
->with('test');
$configurationMock->expects($this->once())
->method('setName')
->with('test');
$configurationMock->expects($this->once())
->method('setMigrationsTableName')
->with('test');
$configurationMock->expects($this->once())
->method('setMigrationsColumnName')
->with('version');
$configurationMock->expects($this->once())
->method('setMigrationsColumnLength')
->with(255);
$configurationMock->expects($this->once())
->method('setMigrationsColumnLength')
->with(255);
$configurationMock->expects($this->once())
->method('setMigrationsExecutedAtColumnName')
->with('executed_at');
$configurationMock->expects($this->once())
->method('setMigrationsAreOrganizedByYear')
->with(true);
$configurationMock->expects($this->once())
->method('setAllOrNothing')
->with(false);
DoctrineCommand::configureMigrations($this->getContainer(), $configurationMock);
}
private function getContainer() : ContainerBuilder
{
return new ContainerBuilder(new ParameterBag([
'doctrine_migrations.dir_name' => $this->migrationsDirectory,
'doctrine_migrations.namespace' => 'test',
'doctrine_migrations.name' => 'test',
'doctrine_migrations.table_name' => 'test',
'doctrine_migrations.column_name' => 'version',
'doctrine_migrations.column_length' => 255,
'doctrine_migrations.executed_at_column_name' => 'executed_at',
'doctrine_migrations.organize_migrations' => Configuration::VERSIONS_ORGANIZATION_BY_YEAR,
'doctrine_migrations.custom_template' => null,
'doctrine_migrations.all_or_nothing' => false,
]));
}
}