@@ -59,7 +59,10 @@ public function testAddTaggedTypes()
59
59
), $ extDefinition ->getArgument (1 ));
60
60
}
61
61
62
- public function testAddTaggedTypeExtensions ()
62
+ /**
63
+ * @dataProvider addTaggedTypeExtensionsDataProvider
64
+ */
65
+ public function testAddTaggedTypeExtensions (array $ extensions , array $ expectedRegisteredExtensions )
63
66
{
64
67
$ container = new ContainerBuilder ();
65
68
$ container ->addCompilerPass (new FormPass ());
@@ -72,26 +75,49 @@ public function testAddTaggedTypeExtensions()
72
75
));
73
76
74
77
$ container ->setDefinition ('form.extension ' , $ extDefinition );
75
- $ container ->register ('my.type_extension1 ' , 'stdClass ' )
76
- ->addTag ('form.type_extension ' , array ('extended_type ' => 'type1 ' ));
77
- $ container ->register ('my.type_extension2 ' , 'stdClass ' )
78
- ->addTag ('form.type_extension ' , array ('extended_type ' => 'type1 ' ));
79
- $ container ->register ('my.type_extension3 ' , 'stdClass ' )
80
- ->addTag ('form.type_extension ' , array ('extended_type ' => 'type2 ' ));
78
+
79
+ foreach ($ extensions as $ serviceId => $ tag ) {
80
+ $ container ->register ($ serviceId , 'stdClass ' )->addTag ('form.type_extension ' , $ tag );
81
+ }
81
82
82
83
$ container ->compile ();
83
84
84
85
$ extDefinition = $ container ->getDefinition ('form.extension ' );
86
+ $ this ->assertSame ($ expectedRegisteredExtensions , $ extDefinition ->getArgument (2 ));
87
+ }
85
88
86
- $ this ->assertSame (array (
87
- 'type1 ' => array (
88
- 'my.type_extension1 ' ,
89
- 'my.type_extension2 ' ,
89
+ /**
90
+ * @return array
91
+ */
92
+ public function addTaggedTypeExtensionsDataProvider ()
93
+ {
94
+ return array (
95
+ array (
96
+ array (
97
+ 'my.type_extension1 ' => array ('extended_type ' => 'type1 ' ),
98
+ 'my.type_extension2 ' => array ('extended_type ' => 'type1 ' ),
99
+ 'my.type_extension3 ' => array ('extended_type ' => 'type2 ' ),
100
+ ),
101
+ array (
102
+ 'type1 ' => array ('my.type_extension1 ' , 'my.type_extension2 ' ),
103
+ 'type2 ' => array ('my.type_extension3 ' ),
104
+ ),
90
105
),
91
- 'type2 ' => array (
92
- 'my.type_extension3 ' ,
106
+ array (
107
+ array (
108
+ 'my.type_extension1 ' => array ('extended_type ' => 'type1 ' , 'priority ' => 1 ),
109
+ 'my.type_extension2 ' => array ('extended_type ' => 'type1 ' , 'priority ' => 2 ),
110
+ 'my.type_extension3 ' => array ('extended_type ' => 'type1 ' , 'priority ' => -1 ),
111
+ 'my.type_extension4 ' => array ('extended_type ' => 'type2 ' , 'priority ' => 2 ),
112
+ 'my.type_extension5 ' => array ('extended_type ' => 'type2 ' , 'priority ' => 1 ),
113
+ 'my.type_extension6 ' => array ('extended_type ' => 'type2 ' , 'priority ' => 1 ),
114
+ ),
115
+ array (
116
+ 'type1 ' => array ('my.type_extension2 ' , 'my.type_extension1 ' , 'my.type_extension3 ' ),
117
+ 'type2 ' => array ('my.type_extension4 ' , 'my.type_extension5 ' , 'my.type_extension6 ' ),
118
+ ),
93
119
),
94
- ), $ extDefinition -> getArgument ( 2 )) ;
120
+ );
95
121
}
96
122
97
123
/**
0 commit comments