-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-31588: Aligned search engine tags to convention
- Loading branch information
Showing
7 changed files
with
201 additions
and
14 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
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
79 changes: 79 additions & 0 deletions
79
...lishCoreBundle/Tests/DependencyInjection/Compiler/RegisterSearchEngineIndexerPassTest.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,79 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler; | ||
|
||
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\RegisterSearchEngineIndexerPass; | ||
use LogicException; | ||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
final class RegisterSearchEngineIndexerPassTest extends AbstractCompilerPassTestCase | ||
{ | ||
private const EXAMPLE_SERVICE_ID = 'app.search_engine'; | ||
private const EXAMPLE_ALIAS = 'foo'; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->setDefinition('ezpublish.api.search_engine.indexer.factory', new Definition()); | ||
} | ||
|
||
protected function registerCompilerPass(ContainerBuilder $container): void | ||
{ | ||
$container->addCompilerPass(new RegisterSearchEngineIndexerPass()); | ||
} | ||
|
||
/** | ||
* @dataProvider tagsProvider | ||
*/ | ||
public function testRegisterSearchEngineIndexer(string $tag): void | ||
{ | ||
$definition = new Definition(); | ||
$definition->addTag($tag, [ | ||
'alias' => self::EXAMPLE_ALIAS, | ||
]); | ||
|
||
$this->setDefinition(self::EXAMPLE_SERVICE_ID, $definition); | ||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | ||
'ezpublish.api.search_engine.indexer.factory', | ||
'registerSearchEngineIndexer', | ||
[ | ||
new Reference(self::EXAMPLE_SERVICE_ID), | ||
self::EXAMPLE_ALIAS, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider tagsProvider | ||
*/ | ||
public function testRegisterSearchEngineIndexerWithoutAliasThrowsLogicException(string $tag): void | ||
{ | ||
$this->expectException(LogicException::class); | ||
|
||
$definition = new Definition(); | ||
$definition->addTag($tag); | ||
|
||
$this->setDefinition(self::EXAMPLE_SERVICE_ID, $definition); | ||
$this->compile(); | ||
} | ||
|
||
public function tagsProvider(): iterable | ||
{ | ||
return [ | ||
[RegisterSearchEngineIndexerPass::SEARCH_ENGINE_INDEXER_SERVICE_TAG], | ||
[RegisterSearchEngineIndexerPass::DEPRECATED_SEARCH_ENGINE_INDEXER_SERVICE_TAG], | ||
]; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...e/EzPublishCoreBundle/Tests/DependencyInjection/Compiler/RegisterSearchEnginePassTest.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,79 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler; | ||
|
||
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\RegisterSearchEnginePass; | ||
use LogicException; | ||
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
final class RegisterSearchEnginePassTest extends AbstractCompilerPassTestCase | ||
{ | ||
private const EXAMPLE_SERVICE_ID = 'app.search_engine'; | ||
private const EXAMPLE_ALIAS = 'foo'; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->setDefinition('ezpublish.api.search_engine.factory', new Definition()); | ||
} | ||
|
||
protected function registerCompilerPass(ContainerBuilder $container): void | ||
{ | ||
$container->addCompilerPass(new RegisterSearchEnginePass()); | ||
} | ||
|
||
/** | ||
* @dataProvider tagsProvider | ||
*/ | ||
public function testRegisterSearchEngine(string $tag): void | ||
{ | ||
$definition = new Definition(); | ||
$definition->addTag($tag, [ | ||
'alias' => self::EXAMPLE_ALIAS, | ||
]); | ||
|
||
$this->setDefinition(self::EXAMPLE_SERVICE_ID, $definition); | ||
$this->compile(); | ||
|
||
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( | ||
'ezpublish.api.search_engine.factory', | ||
'registerSearchEngine', | ||
[ | ||
new Reference(self::EXAMPLE_SERVICE_ID), | ||
self::EXAMPLE_ALIAS, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider tagsProvider | ||
*/ | ||
public function testRegisterSearchEngineWithoutAliasThrowsLogicException(string $tag): void | ||
{ | ||
$this->expectException(LogicException::class); | ||
|
||
$definition = new Definition(); | ||
$definition->addTag($tag); | ||
|
||
$this->setDefinition(self::EXAMPLE_SERVICE_ID, $definition); | ||
$this->compile(); | ||
} | ||
|
||
public function tagsProvider(): iterable | ||
{ | ||
return [ | ||
[RegisterSearchEnginePass::SEARCH_ENGINE_SERVICE_TAG], | ||
[RegisterSearchEnginePass::DEPRECATED_SEATCH_ENGINE_SERVICE_TAG], | ||
]; | ||
} | ||
} |
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