33namespace Gedmo \Timestampable ;
44
55use Doctrine \Common \EventManager ;
6+ use Timestampable \Fixture \Author ;
67use Tool \BaseTestCaseORM ;
78use Timestampable \Fixture \Article ;
89use Timestampable \Fixture \Comment ;
@@ -93,6 +94,12 @@ function shouldHandleStandardBehavior()
9394 $ sportComment ->setArticle ($ sport );
9495 $ sportComment ->setStatus (0 );
9596
97+ $ author = new Author ();
98+ $ author ->setName ('Original author ' );
99+ $ author->
setEmail (
'[email protected] ' );
100+
101+ $ sport ->setAuthor ($ author );
102+
96103 $ this ->em ->persist ($ sport );
97104 $ this ->em ->persist ($ sportComment );
98105 $ this ->em ->flush ();
@@ -102,6 +109,11 @@ function shouldHandleStandardBehavior()
102109 $ this ->assertNotNull ($ su = $ sport ->getUpdated ());
103110 $ this ->assertNull ($ sport ->getContentChanged ());
104111 $ this ->assertNull ($ sport ->getPublished ());
112+ $ this ->assertNull ($ sport ->getAuthorChanged ());
113+
114+ $ author = $ sport ->getAuthor ();
115+ $ author ->setName ('New author ' );
116+ $ sport ->setAuthor ($ author );
105117
106118 $ sportComment = $ this ->em ->getRepository (self ::COMMENT )->findOneByMessage ('hello ' );
107119 $ this ->assertNotNull ($ scm = $ sportComment ->getModified ());
@@ -120,6 +132,7 @@ function shouldHandleStandardBehavior()
120132 $ sportComment = $ this ->em ->getRepository (self ::COMMENT )->findOneByMessage ('hello ' );
121133 $ this ->assertNotNull ($ scc = $ sportComment ->getClosed ());
122134 $ this ->assertNotNull ($ sp = $ sport ->getPublished ());
135+ $ this ->assertNotNull ($ sa = $ sport ->getAuthorChanged ());
123136
124137 $ sport ->setTitle ('Updated ' );
125138 $ this ->em ->persist ($ sport );
@@ -131,6 +144,11 @@ function shouldHandleStandardBehavior()
131144 $ this ->assertNotSame ($ su2 = $ sport ->getUpdated (), $ su , "Date updated should change after update " );
132145 $ this ->assertSame ($ sport ->getPublished (), $ sp , "Date published should remain the same after update " );
133146 $ this ->assertNotSame ($ scc2 = $ sport ->getContentChanged (), $ scc , "Content must have changed after update " );
147+ $ this ->assertSame ($ sport ->authorChanged (), $ sa , "Author should remain same after update " );
148+
149+ $ author = $ sport ->getAuthor ();
150+ $ author ->setName ('Third author ' );
151+ $ sport ->setAuthor ($ author );
134152
135153 $ sport ->setBody ('Body updated ' );
136154 $ this ->em ->persist ($ sport );
@@ -142,6 +160,7 @@ function shouldHandleStandardBehavior()
142160 $ this ->assertNotSame ($ sport ->getUpdated (), $ su2 , "Date updated should change after update " );
143161 $ this ->assertSame ($ sport ->getPublished (), $ sp , "Date published should remain the same after update " );
144162 $ this ->assertNotSame ($ sport ->getContentChanged (), $ scc2 , "Content must have changed after update " );
163+ $ this ->assertNotSame ($ sport ->getAuthorChanged (), $ sa , "Author must have changed after update " );
145164 }
146165
147166 /**
0 commit comments