Code Duplication    Length = 23-23 lines in 2 locations

tests/CommentingControllerTest.php 2 locations

@@ 34-56 (lines=23) @@
31
        $this->securityEnabled = SecurityToken::is_enabled();
32
    }
33
34
    public function testApprove()
35
    {
36
        SecurityToken::disable();
37
38
        // mark a comment as spam then approve it
39
        $this->logInWithPermission('CMS_ACCESS_CommentAdmin');
40
        $comment = $this->objFromFixture('Comment', 'firstComA');
41
        $comment->markSpam();
42
        $st = new Comment_SecurityToken($comment);
43
        $url = 'CommentingController/approve/' . $comment->ID;
44
        $url = $st->addToUrl($url, Member::currentUser());
45
        $response = $this->get($url);
46
        $this->assertEquals(200, $response->getStatusCode());
47
        $comment = DataObject::get_by_id('Comment', $comment->ID);
48
49
        // Need to use 0,1 here instead of false, true for SQLite
50
        $this->assertEquals(0, $comment->IsSpam);
51
        $this->assertEquals(1, $comment->Moderated);
52
53
        // try and approve a non existent comment
54
        $response = $this->get('CommentingController/approve/100000');
55
        $this->assertEquals(404, $response->getStatusCode());
56
    }
57
58
    public function testSetGetOwnerController()
59
    {
@@ 67-89 (lines=23) @@
64
        $this->assertNull($commController->getOwnerController());
65
    }
66
67
    public function testHam()
68
    {
69
        SecurityToken::disable();
70
71
        // mark a comment as spam then ham it
72
        $this->logInWithPermission('CMS_ACCESS_CommentAdmin');
73
        $comment = $this->objFromFixture('Comment', 'firstComA');
74
        $comment->markSpam();
75
        $st = new Comment_SecurityToken($comment);
76
        $url = 'CommentingController/ham/' . $comment->ID;
77
        $url = $st->addToUrl($url, Member::currentUser());
78
        $response = $this->get($url);
79
        $this->assertEquals(200, $response->getStatusCode());
80
        $comment = DataObject::get_by_id('Comment', $comment->ID);
81
82
        // Need to use 0,1 here instead of false, true for SQLite
83
        $this->assertEquals(0, $comment->IsSpam);
84
        $this->assertEquals(1, $comment->Moderated);
85
86
        // try and ham a non existent comment
87
        $response = $this->get('CommentingController/ham/100000');
88
        $this->assertEquals(404, $response->getStatusCode());
89
    }
90
91
    public function testSpam()
92
    {