PackageProvider example

/** * @internal * * @covers \Shopware\Core\Framework\Plugin\Util\PluginFinder */
class PluginFinderTest extends TestCase
{
    public function testFailsOnMissingRootComposerFile(): void
    {
        $errors = new ExceptionCollection();
        (new PluginFinder(new PackageProvider()))->findPlugins(
            __DIR__,
            __DIR__ . '/../../../../../..',
            $errors,
            new NullIO()
        );

        static::assertInstanceOf(PluginComposerJsonInvalidException::class$errors->first());
    }

    public function testLocalLoadsTheComposerJsonContents(): void
    {
        
$packageProvider = $this->createProvider();
        $pluginPath = __DIR__ . '/invalid_path';

        $this->expectException(PluginComposerJsonInvalidException::class);
        $this->expectExceptionMessage('The file "' . $pluginPath . '/composer.json" is not readable.');

        $packageProvider->getPluginComposerPackage($pluginPathnew NullIO());
    }

    private function createProvider(): PackageProvider
    {
        return new PackageProvider();
    }
}
Home | Imprint | This part of the site doesn't use cookies.