From 638b309b699950e943b3d2c65197c8e39e3fbf29 Mon Sep 17 00:00:00 2001 From: Morven Lewis-Everley Date: Wed, 6 Aug 2014 15:37:42 +0100 Subject: [PATCH] Add test to check that populate defaults works as expected --- tests/BlogEntryTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/BlogEntryTest.php b/tests/BlogEntryTest.php index 99afadf..fe4e2b5 100644 --- a/tests/BlogEntryTest.php +++ b/tests/BlogEntryTest.php @@ -6,6 +6,29 @@ */ class BlogEntryTest extends SapphireTest { static $fixture_file = 'blog/tests/BlogTest.yml'; + + /** + * Tests that the blog entry populate defaults works + */ + public function testPopulateDefaults() { + $member = $this->objFromFixture("Member", "blogOwner1"); + $member->logIn(); + + // Create manually, as from fixture seems to create entries + // multiple times + $entry = BlogEntry::create(); + $entry->Title = "Test post"; + $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($member->getName(), $entry->Author); + + $member->logOut(); + } /** * Tests BBCode functionality