Skip to content

Commit

Permalink
Merge branch 'sw-25250/5.6/fix-plugin-resources' into '5.6'
Browse files Browse the repository at this point in the history
SW-25250 - Fix plugin resource registration

See merge request shopware/5/product/shopware!279
  • Loading branch information
shyim committed Mar 3, 2020
2 parents ebb23cb + 83cf5d1 commit 11a190f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
8 changes: 8 additions & 0 deletions UPGRADE-5.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This changelog references changes done in Shopware 5.6 patch versions.

## 5.6.6

[View all changes from v5.6.5...v5.6.6](https://github.com/shopware/shopware/compare/v5.6.5...v5.6.6)

### Changes

* Changed `\Shopware\Components\DependencyInjection\Compiler\PluginResourceCompilerPass` to work correctly with multiple plugins

## 5.6.5

[View all changes from v5.6.4...v5.6.5](https://github.com/shopware/shopware/compare/v5.6.4...v5.6.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function process(ContainerBuilder $container): void
}

if (!$definition->hasTag('shopware.event_listener')) {
return;
continue;
}

$container->setDefinition($plugin->getContainerPrefix() . '.internal.resource_subscriber', $definition);
Expand Down
36 changes: 36 additions & 0 deletions tests/Unit/Components/Plugin/PluginResourceCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use PHPUnit\Framework\TestCase;
use Shopware\Components\DependencyInjection\Compiler\PluginResourceCompilerPass;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\ResourceSubscriber;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class PluginResourceCompilerPassTest extends TestCase
Expand Down Expand Up @@ -107,4 +108,39 @@ public function testWithEnabledAutoload(): void
// JS, CSS, LESS, FRONTEND TPL, BACKEND TPL
static::assertCount(5, $tags);
}

public function testTwoPlugins(): void
{
$emptyPlugin = $this->createMock(Plugin::class);
$emptyPlugin->method('getPath')
->willReturn(__DIR__ . '/examples/EmptyPlugin');

$emptyPlugin
->method('hasAutoloadViews')
->willReturn(true);

$emptyPlugin
->method('getContainerPrefix')
->willReturn('empty_plugin');

$filledPlugin = $this->createMock(Plugin::class);
$filledPlugin->method('getPath')
->willReturn(__DIR__ . '/examples/TestPlugin');

$filledPlugin
->method('hasAutoloadViews')
->willReturn(true);

$filledPlugin
->method('getContainerPrefix')
->willReturn('filled_plugin');

$container = new ContainerBuilder();
$container->addCompilerPass(new PluginResourceCompilerPass([$emptyPlugin, $filledPlugin]));
$container->compile();

static::assertCount(2, $container->getDefinitions());

static::assertInstanceOf(ResourceSubscriber::class, $container->get('filled_plugin.internal.resource_subscriber'));
}
}

0 comments on commit 11a190f

Please sign in to comment.