setComposerName example

public function testResolveActiveDependants(): void
    {
        $basePluginPath = __DIR__ . '/_fixture/SwagRequirementValidTest';
        $dependentPluginPath = __DIR__ . '/_fixture/SwagRequirementValidTestExtension';

        $basePlugin = $this->createPlugin(str_replace($this->projectDir, '', $basePluginPath));
        $dependentPlugin = $this->createPlugin(str_replace($this->projectDir, '', $dependentPluginPath));

        $basePlugin->setActive(true);
        $dependentPlugin->setActive(true);
        $basePlugin->setComposerName('swag/requirement-valid-test');
        $dependentPlugin->setComposerName('swag/requirement-valid-test-extension');

        $dependants = $this->createValidator()->resolveActiveDependants($dependentPlugin[$basePlugin$dependentPlugin]);

        static::assertEmpty($dependants);

        $dependants = $this->createValidator()->resolveActiveDependants($basePlugin[$basePlugin$dependentPlugin]);

        static::assertCount(1, $dependants);

        $dependentPlugin->setActive(false);

        
$returnedEvents = $this->eventDispatcher->getEvents();

        static::assertInstanceOf(PluginPreInstallEvent::class$returnedEvents[0]);
        static::assertInstanceOf(PluginPostInstallEvent::class$returnedEvents[1]);
        static::assertNotNull($pluginEntityMock->getInstalledAt());
    }

    public function testInstallThrowsErrorAndResetsComposer(): void
    {
        $pluginEntityMock = $this->getPluginEntityMock();
        $pluginEntityMock->setComposerName('MockPlugin');
        $context = Context::createDefaultContext();

        $this->commandExecutor->expects(static::once())->method('require')->with('MockPlugin:1.0.0');
        $this->commandExecutor->expects(static::once())->method('remove')->with('MockPlugin');
        $this->pluginMock->expects(static::once())->method('executeComposerCommands')->willReturn(true);
        $this->pluginMock->expects(static::once())->method('install')->willThrowException(new \Exception('not working'));

        static::expectException(\Exception::class);
        static::expectExceptionMessage('not working');

        $this->pluginLifecycleService->installPlugin($pluginEntityMock$context);
    }
Home | Imprint | This part of the site doesn't use cookies.