@@ -12,9 +12,14 @@ class ContainerBuilderHasServiceDefinitionConstraintTest extends \PHPUnit_Framew
1212 * @test
1313 * @dataProvider containerBuilderProvider
1414 */
15- public function match (ContainerBuilder $ containerBuilder , $ serviceId , $ expectedClass , $ shouldMatch )
16- {
17- $ constraint = new ContainerBuilderHasServiceDefinitionConstraint ($ serviceId , $ expectedClass );
15+ public function match (
16+ ContainerBuilder $ containerBuilder ,
17+ $ serviceId ,
18+ $ expectedClass ,
19+ $ checkExpectedClass ,
20+ $ shouldMatch
21+ ) {
22+ $ constraint = new ContainerBuilderHasServiceDefinitionConstraint ($ serviceId , $ expectedClass , $ checkExpectedClass );
1823
1924 $ this ->assertSame ($ shouldMatch , $ constraint ->evaluate ($ containerBuilder , '' , true ));
2025 }
@@ -45,17 +50,19 @@ public function containerBuilderProvider()
4550
4651 return array (
4752 // the container does not have the service definition
48- array ($ emptyContainerBuilder , $ serviceId , $ rightClass , false ),
53+ array ($ emptyContainerBuilder , $ serviceId , $ rightClass , true , false ),
4954 // the container has a service definition, but with the wrong class
50- array ($ containerBuilderWithServiceDefinition , $ serviceId , $ wrongClass , false ),
55+ array ($ containerBuilderWithServiceDefinition , $ serviceId , $ wrongClass , true , false ),
5156 // the container has a service definition with the right class
52- array ($ containerBuilderWithServiceDefinition , $ serviceId , $ rightClass , true ),
57+ array ($ containerBuilderWithServiceDefinition , $ serviceId , $ rightClass , true , true ),
5358 // the container has a service definition with the right class, but it's a parameter
54- array ($ containerBuilderWithServiceDefinitionWithParameterClass , $ serviceId , $ rightClass , true ),
59+ array ($ containerBuilderWithServiceDefinitionWithParameterClass , $ serviceId , $ rightClass , true , true ),
5560 // the container has an alias, but with the wrong class
56- array ($ containerBuilderWithAlias , $ aliasId , $ wrongClass , false ),
61+ array ($ containerBuilderWithAlias , $ aliasId , $ wrongClass , true , false ),
5762 // the container has an alias with the right class
58- array ($ containerBuilderWithAlias , $ aliasId , $ rightClass , true )
63+ array ($ containerBuilderWithAlias , $ aliasId , $ rightClass , true , true ),
64+ // giving a class is optional
65+ array ($ containerBuilderWithAlias , $ aliasId , null , false , true ),
5966 );
6067 }
6168
0 commit comments