Completed
Pull Request — master (#3)
by Ramūnas
13:15
created

ConfigurationTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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 testMigrationsIsLoadedOnlyFromCertainPath()
18
    {
19
        $kernel = new Kernel('test', true);
20
        $kernel->setRegistrableBundles(array(
21
            new TestPackageTest1Bundle(),
22
            new TestPackageTest2Bundle(),
23
        ));
24
25
        $kernel->boot();
26
27
        $container = $kernel->getContainer();
28
        $config = $container->getParameter('rdv_migration');
29
        $this->assertEquals(MigrationsLoader::DEFAULT_MIGRATIONS_PATH, $config['migration_path']);
30
31
        /** @var \RDV\Bundle\MigrationBundle\Migration\Loader\MigrationsLoader $loader */
32
        $loader = $container->get('rdv_migration.migrations.loader');
33
        $migrations = $loader->getMigrations();
34
        $this->assertCount(8, $migrations);
35
36
        $kernel->shutdown();
37
        $this->tearDown();
38
        $kernel->setConfigCallback(function ($container) {
39
            $container->setParameter('rdv_migration', array(
40
                'migration_path' => 'NonExistingPath',
41
            ));
42
        });
43
        $kernel->boot();
44
45
        $loader->setMigrationPath('NonExistingPath');
46
        $migrations = $loader->getMigrations();
47
        $this->assertCount(2, $migrations); // 2 migrations comes from this bundle itself, @todo
48
    }
49
}
50