@@ -46,6 +46,10 @@ protected function createBlog($withPosts = false)
46
46
$ this ->getDm ()->clear ();
47
47
}
48
48
49
+ /**
50
+ * It should persist the blog document and create an auto route.
51
+ * It should set the defaults on the route.
52
+ */
49
53
public function testPersistBlog ()
50
54
{
51
55
$ this ->createBlog ();
@@ -62,6 +66,11 @@ public function testPersistBlog()
62
66
$ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute ' , $ routes [0 ]);
63
67
$ this ->assertEquals ('unit-testing-blog ' , $ routes [0 ]->getName ());
64
68
$ this ->assertEquals (PhpcrOdmAdapter::TAG_NO_MULTILANG , $ routes [0 ]->getAutoRouteTag ());
69
+ $ this ->assertEquals (array (
70
+ '_auto_route_tag ' => 'no-multilang ' ,
71
+ 'type ' => 'cmf_routing_auto.primary ' ,
72
+ '_controller ' => 'BlogController ' ,
73
+ ), $ routes [0 ]->getDefaults ());
65
74
}
66
75
67
76
public function provideTestUpdateBlog ()
@@ -206,6 +215,16 @@ public function provideMultilangArticle()
206
215
'test/auto-route/articles/fr/bonjour-le-monde ' ,
207
216
'test/auto-route/articles/de/gutentag ' ,
208
217
'test/auto-route/articles/es/hola-todo-el-mundo ' ,
218
+
219
+ 'test/auto-route/articles/en/hello-everybody-edit ' ,
220
+ 'test/auto-route/articles/fr/bonjour-le-monde-edit ' ,
221
+ 'test/auto-route/articles/de/gutentag-edit ' ,
222
+ 'test/auto-route/articles/es/hola-todo-el-mundo-edit ' ,
223
+
224
+ 'test/auto-route/articles/en/hello-everybody-review ' ,
225
+ 'test/auto-route/articles/fr/bonjour-le-monde-review ' ,
226
+ 'test/auto-route/articles/de/gutentag-review ' ,
227
+ 'test/auto-route/articles/es/hola-todo-el-mundo-review ' ,
209
228
),
210
229
),
211
230
);
@@ -231,11 +250,12 @@ public function testMultilangArticle($data, $expectedPaths)
231
250
$ locales = array_keys ($ data );
232
251
233
252
foreach ($ expectedPaths as $ i => $ expectedPath ) {
234
- $ expectedLocale = $ locales [$ i ];
253
+ $ localeIndex = $ i % count ($ locales );
254
+ $ expectedLocale = $ locales [$ localeIndex ];
235
255
236
256
$ route = $ this ->getDm ()->find (null , $ expectedPath );
237
257
238
- $ this ->assertNotNull ($ route );
258
+ $ this ->assertNotNull ($ route, ' Route: ' . $ expectedPath );
239
259
$ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute ' , $ route );
240
260
$ this ->assertEquals ($ expectedLocale , $ route ->getAutoRouteTag ());
241
261
@@ -317,11 +337,13 @@ public function testUpdateMultilangArticle($data, $expectedPaths)
317
337
318
338
$ article_de = $ this ->getDm ()->findTranslation ('Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Article ' , '/test/article-1 ' , 'de ' );
319
339
$ routes = $ this ->getDm ()->getReferrers ($ article_de );
320
- $ this ->assertCount (count ($ data ), $ routes );
340
+
341
+ // Multiply the expected paths by 3 because Article has 3 routes defined.
342
+ $ this ->assertCount (count ($ data ) * 3 , $ routes );
321
343
322
344
$ this ->getDm ()->clear ();
323
345
324
- foreach ($ expectedPaths as $ i => $ expectedPath ) {
346
+ foreach ($ expectedPaths as $ expectedPath ) {
325
347
$ route = $ this ->getDm ()->find (null , $ expectedPath );
326
348
327
349
$ this ->assertNotNull ($ route );
0 commit comments