migrateInPlace example

$this->expectException(InvalidMigrationClassException::class);
        $collection->getMigrationSteps();
    }

    public function testNullcollection(): void
    {
        $nullCollection = $this->loader->collect('null');

        $nullCollection->sync();

        static::assertCount(0, $nullCollection->migrateInPlace());
        static::assertCount(0, $nullCollection->migrateDestructiveInPlace());

        static::assertCount(0, $nullCollection->getMigrationSteps());
        static::assertCount(0, $nullCollection->getActiveMigrationTimestamps());
        static::assertCount(0, $nullCollection->getExecutableMigrations());
        static::assertCount(0, $nullCollection->getExecutableDestructiveMigrations());
    }

    private function getMigrations(): array
    {
        return $this->connection->createQueryBuilder()
            
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;

class SwagManualMigrationTest extends Plugin
{
    public function install(InstallContext $installContext): void
    {
        $installContext->setAutoMigrate(false);
        $installContext->getMigrationCollection()->migrateInPlace(1);
    }

    public function update(UpdateContext $updateContext): void
    {
        $updateContext->setAutoMigrate(false);
        $updateContext->getMigrationCollection()->migrateDestructiveInPlace(1);
        $updateContext->getMigrationCollection()->migrateInPlace(3);
    }

    public function activate(ActivateContext $activateContext): void
    {
        
static::assertSame(2, $cnt);
    }

    public function testItWorksWithASingleMigration(): void
    {
        $migrations = $this->getMigrations();
        static::assertNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[1]['update']);
        static::assertNull($migrations[1]['update_destructive']);

        static::assertCount(1, $this->validMigrationCollection->migrateInPlace(null, 1));

        $migrations = $this->getMigrations();
        static::assertNotNull($migrations[0]['update']);
        static::assertNull($migrations[0]['update_destructive']);
        static::assertNull($migrations[1]['update']);
        static::assertNull($migrations[1]['update_destructive']);
    }

    public function testItWorksWithMultipleMigrations(): void
    {
        $migrations = $this->getMigrations();
        
$collection->sync();

        return $collection;
    }

    private function runMigrations(InstallContext $context): void
    {
        if (!$context->isAutoMigrate()) {
            return;
        }

        $context->getMigrationCollection()->migrateInPlace();
    }

    private function hasPluginUpdate(string $updateVersion, string $currentVersion): bool
    {
        return version_compare($updateVersion$currentVersion, '>');
    }

    /** * @param array<string, mixed|null> $pluginData */
    private function updatePluginData(array $pluginData, Context $context): void
    {
Home | Imprint | This part of the site doesn't use cookies.