-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from webgriffe/issue-15
Allow to add custom value handlers to the resolver with service tag
- Loading branch information
Showing
4 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/Integration/DependencyInjection/CompilerPassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Webgriffe\SyliusAkeneoPlugin\Integration\DependencyInjection; | ||
|
||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Webgriffe\SyliusAkeneoPlugin\DependencyInjection\WebgriffeSyliusAkeneoExtension; | ||
use Webgriffe\SyliusAkeneoPlugin\ValueHandler\GenericPropertyValueHandler; | ||
|
||
final class CompilerPassTest extends AbstractCompilerPassTestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function adds_tagged_value_handlers_to_resolver(): void | ||
{ | ||
$valueHandlersResolverDefinition = new Definition(); | ||
$this->setDefinition( | ||
'webgriffe_sylius_akeneo.product.value_handlers_resolver', | ||
$valueHandlersResolverDefinition | ||
); | ||
$taggedValueHandlerDefinition = new Definition( | ||
GenericPropertyValueHandler::class, | ||
[ | ||
new Reference('property_accessor'), | ||
'akeneo_attribute', | ||
'sylius_property', | ||
] | ||
); | ||
$taggedValueHandlerDefinition->addTag('webgriffe_sylius_akeneo.product.value_handler', ['priority' => 42]); | ||
$this->container->setDefinition('app.my.custom.value_handler', $taggedValueHandlerDefinition); | ||
|
||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasService('webgriffe_sylius_akeneo.product.value_handlers_resolver'); | ||
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | ||
'webgriffe_sylius_akeneo.product.value_handlers_resolver', | ||
'add', | ||
[new Reference('app.my.custom.value_handler'), 42] | ||
); | ||
} | ||
|
||
protected function registerCompilerPass(ContainerBuilder $container): void | ||
{ | ||
$container->addCompilerPass(new WebgriffeSyliusAkeneoExtension()); | ||
} | ||
} |