|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Oro\Bundle\WebsiteBundle\Tests\Unit\DependencyInjection\CompilerPass; |
| 4 | + |
| 5 | +use Oro\Bundle\WebsiteBundle\DependencyInjection\CompilerPass\AssetsRouterPass; |
| 6 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 7 | +use Symfony\Component\DependencyInjection\Definition; |
| 8 | +use Symfony\Component\DependencyInjection\Reference; |
| 9 | + |
| 10 | +class AssetsRouterPassTest extends \PHPUnit\Framework\TestCase |
| 11 | +{ |
| 12 | + /** @var ContainerBuilder|\PHPUnit\Framework\MockObject\MockObject */ |
| 13 | + private $containerBuilder; |
| 14 | + |
| 15 | + /** @var AssetsRouterPass */ |
| 16 | + private $compilerPass; |
| 17 | + |
| 18 | + protected function setUp(): void |
| 19 | + { |
| 20 | + $this->containerBuilder = $this->createMock(ContainerBuilder::class); |
| 21 | + |
| 22 | + $this->compilerPass = new AssetsRouterPass(); |
| 23 | + } |
| 24 | + |
| 25 | + public function testProcess(): void |
| 26 | + { |
| 27 | + $routerDefinition = $this->createMock(Definition::class); |
| 28 | + $routerDefinition->expects($this->once()) |
| 29 | + ->method('replaceArgument') |
| 30 | + ->with(3, new Reference('oro_website.asset.request_context')); |
| 31 | + |
| 32 | + $generatorDefinition = $this->createMock(Definition::class); |
| 33 | + $generatorDefinition->expects($this->once()) |
| 34 | + ->method('replaceArgument') |
| 35 | + ->with(0, new Reference('oro_website.asset.router')); |
| 36 | + |
| 37 | + $cacheManagerDefinition = $this->createMock(Definition::class); |
| 38 | + $cacheManagerDefinition->expects($this->once()) |
| 39 | + ->method('replaceArgument') |
| 40 | + ->with(1, new Reference('oro_website.asset.router')); |
| 41 | + |
| 42 | + $cacheResolverDefinition = $this->createMock(Definition::class); |
| 43 | + $cacheResolverDefinition->expects($this->once()) |
| 44 | + ->method('replaceArgument') |
| 45 | + ->with(1, new Reference('oro_website.asset.request_context')); |
| 46 | + |
| 47 | + $consumptionExtension = $this->createMock(Definition::class); |
| 48 | + $consumptionExtension->expects($this->once()) |
| 49 | + ->method('replaceArgument') |
| 50 | + ->with(0, new Reference('oro_website.asset.request_context')); |
| 51 | + |
| 52 | + $this->containerBuilder->expects($this->any()) |
| 53 | + ->method('getDefinition') |
| 54 | + ->willReturnMap( |
| 55 | + [ |
| 56 | + ['oro_website.asset.router', $routerDefinition], |
| 57 | + ['oro_attachment.url_generator', $generatorDefinition], |
| 58 | + ['liip_imagine.cache.manager', $cacheManagerDefinition], |
| 59 | + ['liip_imagine.cache.resolver.default', $cacheResolverDefinition], |
| 60 | + ['oro_ui.consumption_extension.request_context', $consumptionExtension], |
| 61 | + ] |
| 62 | + ); |
| 63 | + |
| 64 | + $this->compilerPass->process($this->containerBuilder); |
| 65 | + } |
| 66 | +} |
0 commit comments