@@ -44,17 +44,31 @@ public function testPersistBlog()
44
44
$ this ->assertEquals ('unit-testing-blog ' , $ routes [0 ]->getName ());
45
45
}
46
46
47
- public function testUpdateBlog ()
47
+ public function provideTestUpdateBlog ()
48
48
{
49
- $ this ->createBlog ();
49
+ return array (
50
+ array (false ),
51
+ array (true ),
52
+ );
53
+ }
54
+
55
+ /**
56
+ * @dataProvider provideTestUpdateBlog
57
+ */
58
+ public function testUpdateBlog ($ withPosts = false )
59
+ {
60
+ $ this ->createBlog ($ withPosts );
50
61
51
62
$ blog = $ this ->getDm ()->find (null , '/test/test-blog ' );
52
63
// test update
53
64
$ blog ->title = 'Foobar ' ;
54
65
$ this ->getDm ()->persist ($ blog );
55
66
$ this ->getDm ()->flush ();
56
67
68
+ // note: The NAME stays the same, its the ID not the title
57
69
$ blog = $ this ->getDm ()->find (null , '/test/test-blog ' );
70
+ $ this ->assertNotNull ($ blog );
71
+
58
72
$ routes = $ blog ->routes ;
59
73
60
74
$ this ->assertCount (1 , $ routes );
@@ -64,6 +78,16 @@ public function testUpdateBlog()
64
78
65
79
$ this ->assertEquals ('foobar ' , $ routes [0 ]->getName ());
66
80
$ this ->assertEquals ('/test/auto-route/blog/foobar ' , $ routes [0 ]->getId ());
81
+
82
+ if ($ withPosts ) {
83
+ $ post = $ this ->getDm ()->find (null , '/test/test-blog/This is a post title ' );
84
+ $ this ->assertNotNull ($ post );
85
+
86
+ $ routes = $ post ->routes ;
87
+ $ this ->getDm ()->refresh ($ routes [0 ]);
88
+
89
+ $ this ->assertEquals ('/test/auto-route/blog/foobar/2013/03/21/this-is-a-post-title ' , $ routes [0 ]->getId ());
90
+ }
67
91
}
68
92
69
93
public function testRemoveBlog ()
0 commit comments