setBaseClass example

foreach ($rules as $rule) {
            static::assertEquals(0, $rule['invalid']);
            static::assertNull($rule['payload']);
            static::assertNotNull($rule['id']);
        }
    }

    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()
        );

        
$eventMock = $this->createMock(PluginPostActivateEvent::class);
        $eventMock->expects(static::once())->method('getContext')->willReturn($activateContextMock);
        $eventMock->expects(static::never())->method('getPlugin');

        $this->pluginSubscriber->pluginPostActivate($eventMock);
    }

    public function testPluginPostActivate(): void
    {
        $pluginMock = new PluginEntity();
        $pluginMock->setPath('');
        $pluginMock->setBaseClass(FakePlugin::class);
        $eventMock = $this->createMock(PluginPostActivateEvent::class);
        $eventMock->expects(static::exactly(2))->method('getPlugin')->willReturn($pluginMock);
        $this->pluginSubscriber->pluginPostActivate($eventMock);
    }

    public function testPluginPostDeactivateFailed(): void
    {
        $pluginMock = new PluginEntity();
        $pluginMock->setPath('');
        $pluginMock->setBaseClass(FakePlugin::class);

        
$this->pluginLifecycleService->deactivatePlugin($pluginEntityMock$context);
    }

    // ------ DeactivatePlugin -----
    // ++++++ privates +++++++
    public function testPluginBaseClassNotSet(): void
    {
        $pluginEntityMock = new PluginEntity();
        $pluginEntityMock->setBaseClass('MockPlugin');
        $context = Context::createDefaultContext();

        $this->kernelPluginCollectionMock->method('get')->willReturn(null);

        static::expectException(PluginBaseClassNotFoundException::class);

        $this->pluginLifecycleService->installPlugin($pluginEntityMock$context);
    }

    public function testPluginMigrationCollection(): void
    {
        
$loader->initializePlugins(TEST_PROJECT_DIR);

        static::assertCount(1, $loader->getPluginInfos());
        $kernelPlugins = $loader->getPluginInstances();
        static::assertCount(1, $kernelPlugins->all());
        static::assertInstanceOf(Plugin::class$kernelPlugins->get($activePluginData['baseClass']));
    }

    public function testNonExistingPluginIsSkipped(): void
    {
        $active = $this->getActivePlugin();
        $active->setBaseClass('SomeNotExistingBaseClass');

        $plugins = [$active->jsonSerialize()];
        $loader = new StaticKernelPluginLoader($this->classLoader, null, $plugins);
        $loader->initializePlugins(TEST_PROJECT_DIR);

        static::assertCount(1, $loader->getPluginInfos());
        $kernelPlugins = $loader->getPluginInstances()->all();
        static::assertCount(0, $kernelPlugins);
    }

    public function testManagedByComposerIsSkipped(): void
    {
Home | Imprint | This part of the site doesn't use cookies.