@@ -115,7 +115,10 @@ public function testWhitespaceInPriorities()
115
115
));
116
116
}
117
117
118
- public function testLoadBasePath ()
118
+ /**
119
+ * @dataProvider getBasePathsTests
120
+ */
121
+ public function testLoadBasePaths ($ phpcrConfig , $ routeBasepathsParameter , $ adminBasePathParameter )
119
122
{
120
123
$ this ->container ->setParameter (
121
124
'kernel.bundles ' ,
@@ -125,22 +128,122 @@ public function testLoadBasePath()
125
128
)
126
129
);
127
130
131
+ if (!isset ($ phpcrConfig ['enabled ' ])) {
132
+ $ phpcrConfig ['enabled ' ] = true ;
133
+ }
134
+
128
135
$ this ->load (array (
129
136
'dynamic ' => array (
130
137
'enabled ' => true ,
131
138
'persistence ' => array (
132
- 'phpcr ' => array (
133
- 'enabled ' => true ,
134
- 'route_basepath ' => '/cms/routes ' ,
135
- ),
139
+ 'phpcr ' => $ phpcrConfig ,
136
140
),
137
141
),
138
142
));
139
143
140
- $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.admin_basepath ' , '/cms/routes ' );
144
+ $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.route_basepaths ' , $ routeBasepathsParameter );
145
+ $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.admin_basepath ' , $ adminBasePathParameter );
146
+ }
147
+
148
+ public function getBasePathsTests ()
149
+ {
150
+ return array (
151
+ array (
152
+ array (),
153
+ array ('/cms/routes ' ),
154
+ '/cms/routes '
155
+ ),
156
+
157
+ array (
158
+ array ('route_basepaths ' => '/cms/test ' ),
159
+ array ('/cms/test ' ),
160
+ '/cms/test '
161
+ ),
162
+
163
+ array (
164
+ array ('route_basepaths ' => array ('/cms/routes ' , '/cms/test ' )),
165
+ array ('/cms/routes ' , '/cms/test ' ),
166
+ '/cms/routes '
167
+ ),
168
+
169
+ array (
170
+ array ('route_basepaths ' => array ('/cms/test ' , '/cms/routes ' )),
171
+ array ('/cms/test ' , '/cms/routes ' ),
172
+ '/cms/test '
173
+ ),
174
+ );
141
175
}
142
176
143
- public function testLoadBasePaths ()
177
+ /**
178
+ * @dataProvider getBasePathsMergingTests
179
+ */
180
+ public function testRouteBasepathsMerging ($ phpcrConfig1 , $ phpcrConfig2 , $ routeBasepathsParameter , $ adminBasePathParameter )
181
+ {
182
+ $ this ->container ->setParameter (
183
+ 'kernel.bundles ' ,
184
+ array (
185
+ 'CmfRoutingBundle ' => true ,
186
+ 'SonataDoctrinePHPCRAdminBundle ' => true ,
187
+ )
188
+ );
189
+
190
+ if (!isset ($ phpcrConfig1 ['enabled ' ])) {
191
+ $ phpcrConfig1 ['enabled ' ] = true ;
192
+ }
193
+ if (!isset ($ phpcrConfig2 ['enabled ' ])) {
194
+ $ phpcrConfig2 ['enabled ' ] = true ;
195
+ }
196
+
197
+ $ configs = array (
198
+ array (
199
+ 'dynamic ' => array (
200
+ 'enabled ' => true ,
201
+ 'persistence ' => array ('phpcr ' => $ phpcrConfig1 ),
202
+ ),
203
+ ),
204
+ array (
205
+ 'dynamic ' => array (
206
+ 'enabled ' => true ,
207
+ 'persistence ' => array ('phpcr ' => $ phpcrConfig2 ),
208
+ ),
209
+ ),
210
+ );
211
+
212
+ foreach ($ this ->container ->getExtensions () as $ extension ) {
213
+ $ extension ->load ($ configs , $ this ->container );
214
+ }
215
+
216
+ $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.route_basepaths ' , $ routeBasepathsParameter );
217
+ $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.admin_basepath ' , $ adminBasePathParameter );
218
+ }
219
+
220
+ public function getBasePathsMergingTests ()
221
+ {
222
+ return array (
223
+ array (
224
+ array ('route_basepaths ' => array ('/cms/test ' )),
225
+ array ('route_basepaths ' => array ('/cms/test2 ' )),
226
+ array ('/cms/test ' , '/cms/test2 ' ),
227
+ '/cms/test '
228
+ ),
229
+
230
+ array (
231
+ array ('route_basepaths ' => array ('/cms/test ' )),
232
+ array ('route_basepaths ' => array ('/cms/test2 ' , '/cms/test3 ' )),
233
+ array ('/cms/test ' , '/cms/test2 ' , '/cms/test3 ' ),
234
+ '/cms/test '
235
+ ),
236
+
237
+ array (
238
+ array (),
239
+ array ('route_basepaths ' => array ('/cms/test ' )),
240
+ array ('/cms/test ' ),
241
+ '/cms/test '
242
+ ),
243
+ );
244
+ }
245
+
246
+ public function testLegacyRouteBasepath ()
144
247
{
145
248
$ this ->container ->setParameter (
146
249
'kernel.bundles ' ,
@@ -155,15 +258,14 @@ public function testLoadBasePaths()
155
258
'enabled ' => true ,
156
259
'persistence ' => array (
157
260
'phpcr ' => array (
158
- 'enabled ' => true ,
159
- 'route_basepaths ' => array ('/cms/routes ' , '/cms/test ' ),
261
+ 'route_basepath ' => '/cms/test '
160
262
),
161
263
),
162
264
),
163
265
));
164
266
165
- $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.admin_basepath ' , '/cms/routes ' );
166
- $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.route_basepaths ' , array ( '/cms/routes ' , ' /cms/ test ') );
267
+ $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.route_basepaths ' , array ( '/cms/test ' ) );
268
+ $ this ->assertContainerBuilderHasParameter ('cmf_routing.dynamic.persistence.phpcr.admin_basepath ' , '/cms/test ' );
167
269
}
168
270
169
271
public function testInitializerEnabled ()
0 commit comments