File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -441,4 +441,35 @@ public function test_update_our_datetime()
441
441
$ this ->assert_true ($ our_datetime === $ author ->some_date );
442
442
}
443
443
444
+ public function test_touch ()
445
+ {
446
+ $ author = Author::create (array ('name ' => 'MC Hammer ' ));
447
+ $ updated_at = $ author ->updated_at = new DateTime ('yesterday ' );
448
+ $ author ->save ();
449
+ $ author ->touch ();
450
+ $ this ->assertGreaterThan ($ updated_at , $ author ->updated_at );
451
+ }
452
+
453
+ /**
454
+ * @expectedException ActiveRecord\ActiveRecordException
455
+ * @expectedExceptionMessage Cannot touch on a new record object
456
+ */
457
+ public function test_touch_on_new_record ()
458
+ {
459
+ $ author = new Author (array ('name ' => 'MC Hammer ' ));
460
+ $ author ->touch ();
461
+ }
462
+
463
+ public function test_touch_with_additional_keys ()
464
+ {
465
+ $ author = Author::create (array ('name ' => 'MC Hammer ' ));
466
+ $ updated_at = $ author ->updated_at = new DateTime ('yesterday ' );
467
+ $ some_date = $ author ->some_date = new DateTime ('yesterday ' );
468
+ $ author ->save ();
469
+ $ author ->touch (array ('some_date ' ));
470
+ $ this ->assertGreaterThan ($ updated_at , $ author ->updated_at );
471
+ $ this ->assertGreaterThan ($ some_date , $ author ->some_date );
472
+ }
473
+
474
+
444
475
}
You can’t perform that action at this time.
0 commit comments