mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #10 from micmania1/added-blog-tests
Added category test
This commit is contained in:
commit
6ee356158b
@ -406,3 +406,9 @@ class Blog_Controller extends Page_Controller {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ExtendedBlogPost extends BlogPost implements TestOnly {
|
||||
|
||||
private static $show_in_sitetree = true;
|
||||
|
||||
}
|
27
tests/BlogCategoryTest.php
Executable file
27
tests/BlogCategoryTest.php
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class BlogCategoryTest extends SapphireTest {
|
||||
|
||||
static $fixture_file = "blog.yml";
|
||||
|
||||
public function setUp() {
|
||||
SS_Datetime::set_mock_now("2013-10-10 20:00:00");
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests that any blog posts returned from $category->BlogPosts() many_many are published,
|
||||
* both by normal 'save & publish' functionality and by publish date.
|
||||
**/
|
||||
public function testBlogPosts() {
|
||||
// Ensure the user is not logged in as admin (or anybody)
|
||||
$member = Member::currentUser();
|
||||
if($member) $member->logout();
|
||||
|
||||
$post = $this->objFromFixture("BlogPost", "blogpost1");
|
||||
$category = $this->objFromFixture("BlogCategory", "firstcategory");
|
||||
$this->assertEquals(1, $category->BlogPosts()->count(), "Category blog post count");
|
||||
}
|
||||
|
||||
}
|
@ -9,14 +9,18 @@ class BlogTagTest extends SapphireTest {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that any blog posts returned from $tag->BlogPosts() many_many are published,
|
||||
* both by normal 'save & publish' functionality and by publish date.
|
||||
**/
|
||||
public function testBlogPosts() {
|
||||
// Ensure the user is not logged in as admin (or anybody)
|
||||
$member = Member::currentUser();
|
||||
if($member) $member->logout();
|
||||
|
||||
$post = $this->objFromFixture("BlogPost", "blogpost1");
|
||||
$tag = $this->objFromFixture("BlogTag", "firsttag");
|
||||
$posts = $tag->BlogPosts();
|
||||
$this->assertEquals(1, $posts->count(), "Tag blog post count");
|
||||
$this->assertEquals(1, $tag->BlogPosts()->count(), "Tag blog post count");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ BlogPost:
|
||||
PublishDate: '2013-10-01 15:00:00'
|
||||
Parent: =>Blog.firstblog
|
||||
Tags: =>BlogTag.firsttag
|
||||
Categories: =>BlogCategory.firstcategory
|
||||
blogpost2:
|
||||
Title: 'Second post'
|
||||
URLSegment: second-post
|
||||
@ -40,8 +41,10 @@ BlogPost:
|
||||
URLSegment: future-post
|
||||
PublishDate: '2015-01-01 00:00:00'
|
||||
Tags: =>BlogTag.firsttag
|
||||
Categories: =>BlogCategory.firstcategory
|
||||
futurepost2:
|
||||
Title: 'Future Post 2'
|
||||
URLSegment: future-post-2
|
||||
PublishDate: '2013-11-01 00:00:00'
|
||||
Tags: =>BlogTag.firsttag
|
||||
Categories: =>BlogCategory.firstcategory
|
||||
|
Loading…
Reference in New Issue
Block a user