|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace RDV\Bundle\MigrationBundle\Tests\Functional\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use RDV\Bundle\MigrationBundle\Migration\Loader\MigrationsLoader; |
|
6
|
|
|
use RDV\Bundle\MigrationBundle\Tests\Functional\Fixture\Kernel; |
|
7
|
|
|
use RDV\Bundle\MigrationBundle\Tests\Unit\Fixture\TestPackage\Test1Bundle\TestPackageTest1Bundle; |
|
8
|
|
|
use RDV\Bundle\MigrationBundle\Tests\Unit\Fixture\TestPackage\Test2Bundle\TestPackageTest2Bundle; |
|
9
|
|
|
|
|
10
|
|
|
class ConfigurationTest extends \PHPUnit_Framework_TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
protected function tearDown() |
|
13
|
|
|
{ |
|
14
|
|
|
array_map('unlink', glob(__DIR__ . '/../Fixture/cache/test/*.[php|xml]*')); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function testMigrationsLoadedFromDefaultPath() |
|
18
|
|
|
{ |
|
19
|
|
|
$kernel = new Kernel('test', true); |
|
20
|
|
|
$kernel->setRegistrableBundles( |
|
21
|
|
|
array( |
|
22
|
|
|
new TestPackageTest1Bundle(), |
|
23
|
|
|
new TestPackageTest2Bundle(), |
|
24
|
|
|
) |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
$kernel->boot(); |
|
28
|
|
|
|
|
29
|
|
|
$container = $kernel->getContainer(); |
|
30
|
|
|
$path = $container->getParameter('rdv_migration.migration_path'); |
|
31
|
|
|
$this->assertEquals(MigrationsLoader::DEFAULT_MIGRATIONS_PATH, $path); |
|
32
|
|
|
|
|
33
|
|
|
/** @var \RDV\Bundle\MigrationBundle\Migration\Loader\MigrationsLoader $loader */ |
|
34
|
|
|
$loader = $container->get('rdv_migration.migrations.loader'); |
|
35
|
|
|
$migrations = $loader->getMigrations(); |
|
36
|
|
|
$this->assertCount(8, $migrations); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testMigrationLoadedFromCustomPath() |
|
40
|
|
|
{ |
|
41
|
|
|
$kernel = new Kernel('test', true); |
|
42
|
|
|
$kernel->setRegistrableBundles(array( |
|
43
|
|
|
new TestPackageTest1Bundle(), |
|
44
|
|
|
new TestPackageTest2Bundle(), |
|
45
|
|
|
)); |
|
46
|
|
|
$kernel->setConfigCallback(function ($container) { |
|
47
|
|
|
$container->setParameter('rdv_migration.migration_path', 'NonExistingPath'); |
|
48
|
|
|
}); |
|
49
|
|
|
$kernel->boot(); |
|
50
|
|
|
$container = $kernel->getContainer(); |
|
51
|
|
|
$path = $container->getParameter('rdv_migration.migration_path'); |
|
52
|
|
|
$this->assertEquals('NonExistingPath', $path); |
|
53
|
|
|
|
|
54
|
|
|
$loader = $container->get('rdv_migration.migrations.loader'); |
|
55
|
|
|
$migrations = $loader->getMigrations(); |
|
56
|
|
|
$this->assertCount(2, $migrations); // 2 migrations comes from this bundle itself, @todo |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|