MigrationCollection example


    public function collect(string $name): MigrationCollection
    {
        if (!isset($this->migrationSources[$name])) {
            throw new UnknownMigrationSourceException($name);
        }

        $source = $this->migrationSources[$name];

        return new MigrationCollection($source$this->migrationRuntime, $this->connection, $this->logger);
    }

    public function collectAllForVersion(string $version, string $mode = self::VERSION_SELECTION_ALL): MigrationCollection
    {
        $safeMajorVersion = $this->getLastSafeMajorVersion($version$mode);

        $namespaces = [];
        for ($major = 3; $safeMajorVersion >= 3 && $major <= $safeMajorVersion; ++$major) {
            $namespaces[] = $this->getSource('core.V6_' . $major);
        }
        $namespaces[] = $this->getSource('core');

        
public static function dataProviderForTestPostEventNullsPayload(): array
    {
        $plugin = new PluginEntity();
        $plugin->setName('TestPlugin');
        $plugin->setBaseClass(RulePlugin::class);
        $plugin->setPath('');

        $context = Context::createDefaultContext();
        $rulePlugin = new RulePlugin(false, '');

        $collection = new MigrationCollection(
            new MigrationSource('asd', []),
            new MigrationRuntime(new NullConnection()new NullLogger()),
            new NullConnection()
        );

        return [
            [new PluginPostInstallEvent($pluginnew InstallContext($rulePlugin$context, '', '', $collection))],
            [new PluginPostActivateEvent($pluginnew ActivateContext($rulePlugin$context, '', '', $collection))],
            [new PluginPostUpdateEvent($pluginnew UpdateContext($rulePlugin$context, '', '', $collection, ''))],
            [new PluginPostDeactivateEvent($pluginnew DeactivateContext($rulePlugin$context, '', '', $collection))],
            [new PluginPostUninstallEvent($pluginnew UninstallContext($rulePlugin$context, '', '', $collection, true))],
        ];
static::assertSame(2, $this->getMigrationCount(true));
    }

    public function testCommandMigrateCacheClearBehaviourWithoutMigrations(): void
    {
        static::assertSame(0, $this->getMigrationCount(true));

        $connection = $this->getConnection();
        $loader = $this->getMockBuilder(MigrationCollectionLoader::class)->disableOriginalConstructor()->getMock();

        $loader->expects(static::once())->method('collect')->willReturn(
            new MigrationCollection(
                new MigrationSource(''),
                new MigrationRuntime($connectionnew NullLogger()),
                $connection
            )
        );

        $cache = $this->getMockBuilder(TagAwareAdapter::class)->disableOriginalConstructor()->getMock();
        $cache->expects(static::never())->method('clear');

        $command = new MigrationCommand($loader$cache$this->getContainer()->getParameter('kernel.shopware_version'));

        
Home | Imprint | This part of the site doesn't use cookies.