77namespace Ibexa \Tests \Core \Base \Container \Compiler \Search \Legacy ;
88
99use Ibexa \Core \Base \Container \Compiler \Search \Legacy \CriteriaConverterPass ;
10+ use Ibexa \Core \Persistence \Legacy \URL \Query \CriteriaConverter ;
1011use Matthias \SymfonyDependencyInjectionTest \PhpUnit \AbstractCompilerPassTestCase ;
1112use Symfony \Component \DependencyInjection \ContainerBuilder ;
1213use Symfony \Component \DependencyInjection \Definition ;
@@ -25,67 +26,85 @@ protected function registerCompilerPass(ContainerBuilder $container): void
2526 $ container ->addCompilerPass (new CriteriaConverterPass ());
2627 }
2728
28- public function testAddContentHandlers ()
29+ /**
30+ * @dataProvider provideDescribedServiceToTagName
31+ */
32+ public function testAddHandlers (string $ serviceId , string $ tag ): void
2933 {
3034 $ this ->setDefinition (
31- ' ibexa.search.legacy.gateway.criteria_converter.content ' ,
35+ $ serviceId ,
3236 new Definition ()
3337 );
3438
35- $ serviceId = 'service_id ' ;
3639 $ def = new Definition ();
37- $ def ->addTag (' ibexa.search.legacy.gateway.criterion_handler.content ' );
38- $ this ->setDefinition ($ serviceId , $ def );
40+ $ def ->addTag ($ tag );
41+ $ this ->setDefinition (' service_id ' , $ def );
3942
4043 $ this ->compile ();
4144
4245 $ this ->assertContainerBuilderHasServiceDefinitionWithMethodCall (
43- ' ibexa.search.legacy.gateway.criteria_converter.content ' ,
46+ $ serviceId ,
4447 'addHandler ' ,
45- [new Reference ($ serviceId )]
48+ [new Reference (' service_id ' )]
4649 );
4750 }
4851
49- public function testAddLocationHandlers ()
52+ /**
53+ * @dataProvider provideDescribedServiceToTagName
54+ */
55+ public function testAddContentHandlersWithPriority (string $ serviceId , string $ tag ): void
5056 {
5157 $ this ->setDefinition (
52- ' ibexa.search.legacy.gateway.criteria_converter.location ' ,
58+ $ serviceId ,
5359 new Definition ()
5460 );
5561
56- $ serviceId = 'service_id ' ;
5762 $ def = new Definition ();
58- $ def ->addTag ('ibexa.search.legacy.gateway.criterion_handler.location ' );
59- $ this ->setDefinition ($ serviceId , $ def );
63+ $ def ->addTag ($ tag , ['priority ' => 0 ]);
64+ $ this ->setDefinition ('service_1_id ' , $ def );
65+
66+ $ def = new Definition ();
67+ $ def ->addTag ($ tag , ['priority ' => 100 ]);
68+ $ this ->setDefinition ('service_with_priority ' , $ def );
6069
6170 $ this ->compile ();
6271
6372 $ this ->assertContainerBuilderHasServiceDefinitionWithMethodCall (
64- 'ibexa.search.legacy.gateway.criteria_converter.location ' ,
73+ $ serviceId ,
74+ 'addHandler ' ,
75+ [new Reference ('service_with_priority ' )],
76+ 0 ,
77+ );
78+ $ this ->assertContainerBuilderHasServiceDefinitionWithMethodCall (
79+ $ serviceId ,
6580 'addHandler ' ,
66- [new Reference ($ serviceId )]
81+ [new Reference ('service_1_id ' )],
82+ 1 ,
6783 );
6884 }
6985
70- public function testAddTrashHandlers (): void
86+ /**
87+ * @return iterable<string, string>
88+ */
89+ public static function provideServiceToTagName (): iterable
7190 {
72- $ this ->setDefinition (
73- 'ibexa.core.trash.search.legacy.gateway.criteria_converter ' ,
74- new Definition ()
75- );
91+ yield 'ibexa.search.legacy.gateway.criteria_converter.content ' => 'ibexa.search.legacy.gateway.criterion_handler.content ' ;
7692
77- $ serviceId = 'service_id ' ;
78- $ def = new Definition ();
79- $ def ->addTag ('ibexa.search.legacy.trash.gateway.criterion.handler ' );
80- $ this ->setDefinition ($ serviceId , $ def );
93+ yield 'ibexa.search.legacy.gateway.criteria_converter.location ' => 'ibexa.search.legacy.gateway.criterion_handler.location ' ;
8194
82- $ this -> compile () ;
95+ yield ' ibexa.core.trash.search.legacy.gateway.criteria_converter ' => ' ibexa.search.legacy.trash.gateway.criterion.handler ' ;
8396
84- $ this ->assertContainerBuilderHasServiceDefinitionWithMethodCall (
85- 'ibexa.core.trash.search.legacy.gateway.criteria_converter ' ,
86- 'addHandler ' ,
87- [new Reference ($ serviceId )]
88- );
97+ yield CriteriaConverter::class => 'ibexa.storage.legacy.url.criterion.handler ' ;
98+ }
99+
100+ /**
101+ * @return iterable<string, array{string, string}>
102+ */
103+ public static function provideDescribedServiceToTagName (): iterable
104+ {
105+ foreach (self ::provideServiceToTagName () as $ serviceId => $ tag ) {
106+ yield sprintf ('Service "%s" with tag "%s" ' , $ serviceId , $ tag ) => [$ serviceId , $ tag ];
107+ }
89108 }
90109
91110 public function testAddMultipleHandlers (): void
0 commit comments