| @@ 34-49 (lines=16) @@ | ||
| 31 | * Tests that any blog posts returned from $category->BlogPosts() many_many are published, |
|
| 32 | * both by normal 'save & publish' functionality and by publish date. |
|
| 33 | */ |
|
| 34 | public function testBlogPosts() { |
|
| 35 | $member = Member::currentUser(); |
|
| 36 | ||
| 37 | if($member) { |
|
| 38 | $member->logout(); |
|
| 39 | } |
|
| 40 | ||
| 41 | $this->objFromFixture('BlogPost', 'FirstBlogPost'); |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @var BlogCategory $category |
|
| 45 | */ |
|
| 46 | $category = $this->objFromFixture('BlogCategory', 'FirstCategory'); |
|
| 47 | ||
| 48 | $this->assertEquals(1, $category->BlogPosts()->count(), 'Category blog post count'); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function testCanView() { |
|
| 52 | $this->useDraftSite(); |
|
| @@ 24-41 (lines=18) @@ | ||
| 21 | parent::tearDown(); |
|
| 22 | } |
|
| 23 | ||
| 24 | public function testFilter() { |
|
| 25 | $member = Member::currentUser(); |
|
| 26 | ||
| 27 | if($member) { |
|
| 28 | $member->logout(); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @var Blog $blog |
|
| 33 | */ |
|
| 34 | $blog = $this->objFromFixture('Blog', 'FirstBlog'); |
|
| 35 | ||
| 36 | $this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts'); |
|
| 37 | ||
| 38 | SS_Datetime::set_mock_now('2020-01-01 00:00:00'); |
|
| 39 | ||
| 40 | $this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts'); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 34-49 (lines=16) @@ | ||
| 31 | * Tests that any blog posts returned from $tag->BlogPosts() many_many are published, both by |
|
| 32 | * normal 'save & publish' functionality and by publish date. |
|
| 33 | */ |
|
| 34 | public function testBlogPosts() { |
|
| 35 | $member = Member::currentUser(); |
|
| 36 | ||
| 37 | if($member) { |
|
| 38 | $member->logout(); |
|
| 39 | } |
|
| 40 | ||
| 41 | $this->objFromFixture('BlogPost', 'FirstBlogPost'); |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @var BlogTag $tag |
|
| 45 | */ |
|
| 46 | $tag = $this->objFromFixture('BlogTag', 'FirstTag'); |
|
| 47 | ||
| 48 | $this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count'); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * The first blog can be viewed by anybody. |
|