mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Fixing fragile BlogEntryTest
We can control the time in tests using `mock_now`, so this is being used to guarantee the date is populated correctly.
This commit is contained in:
parent
611865f88f
commit
fdf9317b29
@ -11,6 +11,10 @@ class BlogEntryTest extends SapphireTest {
|
||||
* Tests that the blog entry populate defaults works
|
||||
*/
|
||||
public function testPopulateDefaults() {
|
||||
|
||||
// We cant test by the second, as that will most likely fail
|
||||
SS_Datetime::set_mock_now(SS_Datetime::now());
|
||||
|
||||
$member = $this->objFromFixture("Member", "blogOwner1");
|
||||
$member->logIn();
|
||||
|
||||
@ -21,13 +25,12 @@ class BlogEntryTest extends SapphireTest {
|
||||
$entry->URLSegment = "test-post";
|
||||
$entry->Tags = "tag1,tag2";
|
||||
|
||||
// We cant test by the second, as that will most likely fail
|
||||
$now = date('Y-m-d', strtotime('now'));
|
||||
|
||||
$this->assertContains($now, $entry->Date);
|
||||
$this->assertEquals(SS_Datetime::now()->Rfc2822(), $entry->dbObject('Date')->Rfc2822());
|
||||
$this->assertEquals($member->getName(), $entry->Author);
|
||||
|
||||
$member->logOut();
|
||||
|
||||
SS_Datetime::clear_mock_now();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user