Skip to content

Commit 307db60

Browse files
committed
add some tests
1 parent b7ee409 commit 307db60

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/ActiveRecordWriteTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,35 @@ public function test_update_our_datetime()
441441
$this->assert_true($our_datetime === $author->some_date);
442442
}
443443

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+
444475
}

0 commit comments

Comments
 (0)