getActiveMigrationTimestamps example

use Symfony\Component\DependencyInjection\ContainerBuilder;

#[Package('core')] class MigrationCompilerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        $migrationCollections = $container->get(MigrationCollectionLoader::class)->collectAll();

        $activeCollectionMigrations = [[]];
        foreach ($migrationCollections as $collection) {
            $activeCollectionMigrations[] = $collection->getActiveMigrationTimestamps();
        }

        $container->setParameter('migration.active', array_merge(...$activeCollectionMigrations));
    }
}
static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[0]['message']);
        static::assertNotNull($migrations[0]['class']);
        static::assertNotNull($migrations[0]['creation_timestamp']);
        static::assertEquals(1, $migrationsObjects[0]->getCreationTimestamp());
        static::assertEquals(2, $migrationsObjects[1]->getCreationTimestamp());
    }

    public function testItGetsCorrectMigrationTimestamps(): void
    {
        $collection = $this->loader->collect('_test_migrations_valid');
        $migrations = $collection->getActiveMigrationTimestamps();

        static::assertCount(2, $migrations);
        static::assertEquals(1, $migrations[0]);
        static::assertEquals(2, $migrations[1]);
    }

    public function testThatInvalidMigrationClassesThrowOnLazyInit(): void
    {
        $collection = $this->loader->collect('_test_migrations_invalid_namespace');

        $this->expectException(InvalidMigrationClassException::class);
        
Home | Imprint | This part of the site doesn't use cookies.