| @@ 49-65 (lines=17) @@ | ||
| 46 | * Tests that any blog posts returned from $category->BlogPosts() many_many are published, |
|
| 47 | * both by normal 'save & publish' functionality and by publish date. |
|
| 48 | */ |
|
| 49 | public function testBlogPosts() |
|
| 50 | { |
|
| 51 | $member = Member::currentUser(); |
|
| 52 | ||
| 53 | if ($member) { |
|
| 54 | $member->logout(); |
|
| 55 | } |
|
| 56 | ||
| 57 | $this->objFromFixture('SiteTree', 'FirstBlogPost'); |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @var BlogCategory $category |
|
| 61 | */ |
|
| 62 | $category = $this->objFromFixture('BlogCategory', 'FirstCategory'); |
|
| 63 | ||
| 64 | $this->assertEquals(5, $category->BlogPosts()->count(), 'Category blog post count'); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @see https://github.com/silverstripe/silverstripe-blog/issues/376 |
|
| @@ 39-57 (lines=19) @@ | ||
| 36 | * Tests that unpublished articles are not returned |
|
| 37 | * @covers ::augmentSQL |
|
| 38 | */ |
|
| 39 | public function testFilter() |
|
| 40 | { |
|
| 41 | $member = Member::currentUser(); |
|
| 42 | ||
| 43 | if ($member) { |
|
| 44 | $member->logout(); |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @var Blog $blog |
|
| 49 | */ |
|
| 50 | $blog = $this->objFromFixture('SiteTree', 'FirstBlog'); |
|
| 51 | ||
| 52 | $this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts'); |
|
| 53 | ||
| 54 | DBDatetime::set_mock_now('2020-01-01 00:00:00'); |
|
| 55 | ||
| 56 | $this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts'); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| @@ 49-65 (lines=17) @@ | ||
| 46 | * Tests that any blog posts returned from $tag->BlogPosts() many_many are published, both by |
|
| 47 | * normal 'save & publish' functionality and by publish date. |
|
| 48 | */ |
|
| 49 | public function testBlogPosts() |
|
| 50 | { |
|
| 51 | $member = Member::currentUser(); |
|
| 52 | ||
| 53 | if ($member) { |
|
| 54 | $member->logout(); |
|
| 55 | } |
|
| 56 | ||
| 57 | $this->objFromFixture('SiteTree', 'FirstBlogPost'); |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @var BlogTag $tag |
|
| 61 | */ |
|
| 62 | $tag = $this->objFromFixture('BlogTag', 'FirstTag'); |
|
| 63 | ||
| 64 | $this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count'); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @see https://github.com/silverstripe/silverstripe-blog/issues/376 |
|