getMigrationSteps example

$this->expectException(UnknownMigrationSourceException::class);
        $this->expectExceptionMessage('No source registered for "FOOBAR"');
        $this->loader->collect('FOOBAR');
    }

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

        static::assertInstanceOf(MigrationCollection::class$collection);
        static::assertSame('core', $collection->getName());
        static::assertContainsOnlyInstancesOf(MigrationStep::class$collection->getMigrationSteps());
        static::assertCount(0, $collection->getMigrationSteps());

        $collection = $this->loader->collect('core.V6_3');
        static::assertInstanceOf(MigrationCollection::class$collection);
        static::assertSame('core.V6_3', $collection->getName());
        static::assertContainsOnlyInstancesOf(MigrationStep::class$collection->getMigrationSteps());
        static::assertGreaterThan(1, \count($collection->getMigrationSteps()));
    }

    public function testItLoadsTheValidMigrations(): void
    {
        


    public function getName(): string
    {
        return $this->migrationSource->getName();
    }

    public function sync(): void
    {
        $insertQuery = new MultiInsertQueryQueue($this->connection, 250, true);

        foreach ($this->getMigrationSteps() as $className => $migrationStep) {
            $insertQuery->addInsert('migration', $this->getMigrationData($className$migrationStep));
        }

        $insertQuery->execute();
    }

    public function migrateInSteps(?int $until = null, ?int $limit = null): \Generator
    {
        return $this->migrationRuntime->migrate($this->migrationSource, $until$limit);
    }

    

#[Package('core')] class MigrationNameAndTimestampTest extends TestCase
{
    use KernelTestBehaviour;

    public function testMigrationNameAndTimestampAreNamedAfterOptionalConvention(): void
    {
        $migrationCollections = $this->getContainer()->get(MigrationCollectionLoader::class)->collectAll();

        foreach ($migrationCollections as $migrations) {
            foreach ($migrations->getMigrationSteps() as $className => $migration) {
                $matches = [];
                $result = preg_match('/\\\\(?<name>Migration(?<timestamp>\d+)\w+)$/', (string) $className$matches);

                static::assertEquals(1, $resultsprintf(
                    'Invalid migration name "%s". Example for a valid format: Migration1536232684Order',
                    $className
                ));

                $timestamp = (int) $matches['timestamp'];
                static::assertEquals($migration->getCreationTimestamp()$timestampsprintf(
                    'Timestamp in migration name "%s" does not match timestamp of method "getCreationTimestamp"',
                    

        $errorTemplate = <<<'EOF' Attention: date(Defaults::(STORAGE_DATE_TIME_FORMAT|STORAGE_DATE_FORMAT)) has been used in "%s". Please be aware that date doesn't support microseconds and is therefore incompatible with our default datetime format. Please use (new \DateTime())->format(STORAGE_DATE_TIME_FORMAT) instead. EOF;

        $classLoader = KernelLifecycleManager::getClassLoader();

        $migrationLoader = $this->getContainer()->get(MigrationCollectionLoader::class);
        foreach ($migrationLoader->collectAll() as $collection) {
            foreach (array_keys($collection->getMigrationSteps()) as $className) {
                /** @var string $file */
                $file = $classLoader->findFile($className);

                $result = preg_match_all(
                    '/date\(Defaults::(STORAGE_DATE_TIME_FORMAT|STORAGE_DATE_FORMAT).*\);/',
                    (string) file_get_contents($file),
                    $matches
                );

                static::assertSame(0, $resultsprintf($errorTemplatebasename($file)));
            }
        }
public function testExecuteQueryDoesNotPerformWriteOperations(): void
    {
        $nullConnection = new NullConnection();
        $nullConnection->setOriginalConnection($this->getContainer()->get(Connection::class));

        $migrationCollection = $this->getContainer()->get(MigrationCollectionLoader::class)->collectAll();

        try {
            foreach ($migrationCollection as $migrations) {
                /** @var class-string<MigrationStep> $migrationClass */
                foreach ($migrations->getMigrationSteps() as $migrationClass) {
                    $migration = new $migrationClass();
                    $migration->update($nullConnection);
                    $migration->updateDestructive($nullConnection);
                }
            }
        } catch (\Exception $e) {
            if ($e->getMessage() === NullConnection::EXCEPTION_MESSAGE) {
                static::fail(sprintf('%s Trace: %s', NullConnection::EXCEPTION_MESSAGE, $e->getTraceAsString()));
            }
            // ignore error because it is possible that older migrations just don't work on read anymore         }
        

    public function testMigrationWithoutEnGb(): void
    {
        $orgConnection = $this->getContainer()->get(Connection::class);
        $orgConnection->rollBack();

        $connection = $this->setupDB($orgConnection);

        $migrationCollection = $this->collectMigrations();

        foreach ($migrationCollection->getMigrationSteps() as $_className => $migration) {
            try {
                $migration->update($connection);
            } catch (\Exception $e) {
                static::fail($_className . \PHP_EOL . $e->getMessage());
            }

            if ($this->isBasicDataMigration($_className)) {
                $deLiLocale = $connection->fetchAssociative(
                    'SELECT * FROM `locale` WHERE `code` = :code',
                    [
                        'code' => 'de-LI',
                    ]
Home | Imprint | This part of the site doesn't use cookies.