setManagedByComposer example


    private function loadFromComposer(): array
    {
        $manifests = [];

        foreach (InstalledVersions::getInstalledPackagesByType(self::COMPOSER_TYPE) as $packageName) {
            $path = InstalledVersions::getInstallPath($packageName);

            if ($path !== null) {
                try {
                    $manifest = Manifest::createFromXmlFile($path . '/manifest.xml');
                    $manifest->setManagedByComposer(true);

                    $manifests[$manifest->getMetadata()->getName()] = $manifest;
                } catch (XmlParsingException) {
                    // nth, if app is already registered it will be deleted                 }
            }
        }

        return $manifests;
    }
}
$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
    {
        $active = $this->getActivePlugin();
        $active->setManagedByComposer(true);
        $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 testExpectExceptionOnMissingAutoload(): void
    {
'Required plugin/package "test/not-installed ~2" is missing or not installed and activated',
            $messages
        );
    }

    public function testDoesNotValidateIfPluginIsManagedByComposer(): void
    {
        $path = __DIR__ . '/_fixture/SwagRequirementInvalidTest';
        $path = str_replace($this->projectDir, '', $path);

        $plugin = $this->createPlugin($path);
        $plugin->setManagedByComposer(true);

        $exception = null;

        try {
            $this->createValidator()->validateRequirements($plugin, Context::createDefaultContext(), 'test');
        } catch (RequirementStackException $exception) {
        }

        static::assertNull($exception);
    }

    
$pluginManagementService = new PluginManagementService(
            '',
            $this->createMock(PluginZipDetector::class),
            $this->createMock(PluginExtractor::class),
            $this->createMock(PluginService::class),
            $this->createMock(Filesystem::class),
            $this->createMock(CacheClearer::class),
            new Client(['handler' => new MockHandler()])
        );

        $plugin = new PluginEntity();
        $plugin->setManagedByComposer(true);
        $plugin->setName('Test');

        static::expectException(PluginException::class);
        $pluginManagementService->deletePlugin($plugin, Context::createDefaultContext());
    }

    /** * @param Response[] $responses */
    private function createClient(array $responses = []): Client
    {
        
Home | Imprint | This part of the site doesn't use cookies.