File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
tests/TestCase/Model/Behavior Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,32 @@ public function testInsertOnce()
172172 $ this ->assertCount (1 , $ actual , 'fail insert once. ' );
173173 }
174174
175+ /**
176+ * insertOnce() test add timestamp behavior
177+ *
178+ * @return void
179+ */
180+ public function testInsertOnceAddTimestampBehavior ()
181+ {
182+ $ this ->Articles ->addBehavior ('Timestamp ' );
183+
184+ $ newData = [
185+ 'title ' => 'New Article ' ,
186+ 'body ' => 'New Article Body ' ,
187+ 'published ' => 1
188+ ];
189+ $ entity = $ this ->Articles ->newEntity ($ newData );
190+ $ now = Chronos::now ();
191+
192+ $ this ->Articles ->insertOnce ($ entity );
193+
194+ $ newData ['created ' ] = $ now ;
195+ $ newData ['modified ' ] = $ now ;
196+
197+ $ actual = $ this ->Articles ->exists ($ newData );
198+ $ this ->assertTrue ($ actual , 'fail insert. ' );
199+ }
200+
175201 /**
176202 * insertOnce() test when duplicated
177203 *
You can’t perform that action at this time.
0 commit comments