getMigrationCollectionLoader example

/** * @internal * * @covers \Shopware\Core\Installer\Database\MigrationCollectionFactory */
class MigrationCollectionFactoryTest extends TestCase
{
    public function testGetMigrationCollectionLoader(): void
    {
        $factory = new MigrationCollectionFactory((new TestBootstrapper())->getProjectDir());
        $loader = $factory->getMigrationCollectionLoader(
            $this->createMock(Connection::class)
        );

        static::assertArrayHasKey('core', $loader->collectAll());
        static::assertArrayHasKey('core.V6_3', $loader->collectAll());
        static::assertArrayHasKey('core.V6_4', $loader->collectAll());
        static::assertArrayHasKey('core.V6_5', $loader->collectAll());
    }
}
private readonly SetupDatabaseAdapter $adapter,
        private readonly MigrationCollectionFactory $migrationFactory,
        private readonly string $version
    ) {
    }

    /** * @return array{offset: int, total: int, isFinished: bool} */
    public function migrate(int $offset, Connection $connection): array
    {
        $migrationLoader = $this->migrationFactory->getMigrationCollectionLoader($connection);

        $coreMigrations = $migrationLoader->collectAllForVersion($this->version);

        if ($offset === 0) {
            $this->adapter->initializeShopwareDb($connection);

            $coreMigrations->sync();
        }

        // use 7 s as max execution time, so the UI stays responsive         $maxExecutionTime = min(\ini_get('max_execution_time'), 7);
        
Home | Imprint | This part of the site doesn't use cookies.