Code Duplication    Length = 17-19 lines in 3 locations

tests/BlogCategoryTest.php 1 location

@@ 45-61 (lines=17) @@
42
     * Tests that any blog posts returned from $category->BlogPosts() many_many are published,
43
     * both by normal 'save & publish' functionality and by publish date.
44
     */
45
    public function testBlogPosts()
46
    {
47
        $member = Member::currentUser();
48
49
        if ($member) {
50
            $member->logout();
51
        }
52
53
        $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'FirstBlogPost');
54
55
        /**
56
         * @var BlogCategory $category
57
         */
58
        $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'FirstCategory');
59
60
        $this->assertEquals(5, $category->BlogPosts()->count(), 'Category blog post count');
61
    }
62
63
    /**
64
     * @see https://github.com/silverstripe/silverstripe-blog/issues/376

tests/BlogPostFilterTest.php 1 location

@@ 36-54 (lines=19) @@
33
     * Tests that unpublished articles are not returned
34
     * @covers ::augmentSQL
35
     */
36
    public function testFilter()
37
    {
38
        $member = Member::currentUser();
39
40
        if ($member) {
41
            $member->logout();
42
        }
43
44
        /**
45
         * @var Blog $blog
46
         */
47
        $blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
48
49
        $this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts');
50
51
        DBDatetime::set_mock_now('2020-01-01 00:00:00');
52
53
        $this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts');
54
    }
55
}
56

tests/BlogTagTest.php 1 location

@@ 45-61 (lines=17) @@
42
     * Tests that any blog posts returned from $tag->BlogPosts() many_many are published, both by
43
     * normal 'save & publish' functionality and by publish date.
44
     */
45
    public function testBlogPosts()
46
    {
47
        $member = Member::currentUser();
48
49
        if ($member) {
50
            $member->logout();
51
        }
52
53
        $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'FirstBlogPost');
54
55
        /**
56
         * @var BlogTag $tag
57
         */
58
        $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag');
59
60
        $this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count');
61
    }
62
63
    /**
64
     * @see https://github.com/silverstripe/silverstripe-blog/issues/376