diff --git a/model/Blog.php b/model/Blog.php index 142e0ff..c0f0491 100755 --- a/model/Blog.php +++ b/model/Blog.php @@ -406,3 +406,9 @@ class Blog_Controller extends Page_Controller { } } + +class ExtendedBlogPost extends BlogPost implements TestOnly { + + private static $show_in_sitetree = true; + +} \ No newline at end of file diff --git a/tests/BlogCategoryTest.php b/tests/BlogCategoryTest.php new file mode 100755 index 0000000..e4b7474 --- /dev/null +++ b/tests/BlogCategoryTest.php @@ -0,0 +1,27 @@ +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"); + } + +} diff --git a/tests/BlogTagTest.php b/tests/BlogTagTest.php index 73c20eb..5c3332d 100755 --- a/tests/BlogTagTest.php +++ b/tests/BlogTagTest.php @@ -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"); } } diff --git a/tests/blog.yml b/tests/blog.yml index c4f6c71..796a4e2 100755 --- a/tests/blog.yml +++ b/tests/blog.yml @@ -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