|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Bundle\MigrationsBundle\Tests\DependencyInjection; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Bundle\MigrationsBundle\DependencyInjection\DoctrineMigrationsExtension; |
|
8
|
|
|
use Doctrine\Migrations\Configuration\Configuration; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; |
|
12
|
|
|
use function sys_get_temp_dir; |
|
13
|
|
|
|
|
14
|
|
|
class DoctrineMigrationsExtensionTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
public function testOrganizeMigrations() : void |
|
17
|
|
|
{ |
|
18
|
|
|
$container = $this->getContainer(); |
|
19
|
|
|
$extension = new DoctrineMigrationsExtension(); |
|
20
|
|
|
|
|
21
|
|
|
$config = ['organize_migrations' => 'BY_YEAR']; |
|
22
|
|
|
|
|
23
|
|
|
$extension->load(['doctrine_migrations' => $config], $container); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertEquals( |
|
26
|
|
|
Configuration::VERSIONS_ORGANIZATION_BY_YEAR, |
|
27
|
|
|
$container->getParameter('doctrine_migrations.organize_migrations') |
|
28
|
|
|
); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testForwardCompatibilityLayer() : void |
|
32
|
|
|
{ |
|
33
|
|
|
$container = $this->getContainer(); |
|
34
|
|
|
$extension = new DoctrineMigrationsExtension(); |
|
35
|
|
|
|
|
36
|
|
|
$config = [ |
|
37
|
|
|
'storage' => [ |
|
38
|
|
|
'table_storage' => [ |
|
39
|
|
|
'table_name' => 'doctrine_migration_versions_test', |
|
40
|
|
|
'version_column_name' => 'doctrine_migration_column_test', |
|
41
|
|
|
'version_column_length' => 2000, |
|
42
|
|
|
'executed_at_column_name' => 'doctrine_migration_executed_at_column_test', |
|
43
|
|
|
], |
|
44
|
|
|
], |
|
45
|
|
|
|
|
46
|
|
|
'migrations_paths' => ['DoctrineMigrationsTest' => 'a'], |
|
47
|
|
|
|
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
$extension->load(['doctrine_migrations' => $config], $container); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertEquals('a', $container->getParameter('doctrine_migrations.dir_name')); |
|
53
|
|
|
$this->assertEquals('DoctrineMigrationsTest', $container->getParameter('doctrine_migrations.namespace')); |
|
54
|
|
|
$this->assertEquals('doctrine_migration_versions_test', $container->getParameter('doctrine_migrations.table_name')); |
|
55
|
|
|
$this->assertEquals('doctrine_migration_column_test', $container->getParameter('doctrine_migrations.column_name')); |
|
56
|
|
|
$this->assertEquals(2000, $container->getParameter('doctrine_migrations.column_length')); |
|
57
|
|
|
$this->assertEquals(2000, $container->getParameter('doctrine_migrations.column_length')); |
|
58
|
|
|
$this->assertEquals('doctrine_migration_executed_at_column_test', $container->getParameter('doctrine_migrations.executed_at_column_name')); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
private function getContainer() : ContainerBuilder |
|
62
|
|
|
{ |
|
63
|
|
|
return new ContainerBuilder(new ParameterBag([ |
|
64
|
|
|
'kernel.debug' => false, |
|
65
|
|
|
'kernel.bundles' => [], |
|
66
|
|
|
'kernel.cache_dir' => sys_get_temp_dir(), |
|
67
|
|
|
'kernel.environment' => 'test', |
|
68
|
|
|
'kernel.root_dir' => __DIR__ . '/../../', // src dir |
|
69
|
|
|
])); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|