Code Duplication    Length = 21-23 lines in 2 locations

tests/CommentingControllerTest.php 2 locations

@@ 118-140 (lines=23) @@
115
        $this->assertNull($commController->getOwnerController());
116
    }
117
118
    public function testHam()
119
    {
120
        SecurityToken::inst()->disable();
121
122
        // mark a comment as spam then ham it
123
        $this->logInWithPermission('CMS_ACCESS_CommentAdmin');
124
        $comment = $this->objFromFixture(Comment::class, 'firstComA');
125
        $comment->markSpam();
126
        $st = new CommentSecurityToken($comment);
127
        $url = 'comments/ham/' . $comment->ID;
128
        $url = $st->addToUrl($url, Member::currentUser());
129
        $response = $this->get($url);
130
        $this->assertEquals(302, $response->getStatusCode());
131
        $comment = DataObject::get_by_id(Comment::class, $comment->ID);
132
133
        // Need to use 0,1 here instead of false, true for SQLite
134
        $this->assertEquals(0, $comment->IsSpam);
135
        $this->assertEquals(1, $comment->Moderated);
136
137
        // try and ham a non existent comment
138
        $response = $this->get('comments/ham/100000');
139
        $this->assertEquals(404, $response->getStatusCode());
140
    }
141
142
    public function testSpam()
143
    {
@@ 142-162 (lines=21) @@
139
        $this->assertEquals(404, $response->getStatusCode());
140
    }
141
142
    public function testSpam()
143
    {
144
        // mark a comment as approved then spam it
145
        $this->logInWithPermission('CMS_ACCESS_CommentAdmin');
146
        $comment = $this->objFromFixture(Comment::class, 'firstComA');
147
        $comment->markApproved();
148
        $st = new CommentSecurityToken($comment);
149
        $url = 'comments/spam/' . $comment->ID;
150
        $url = $st->addToUrl($url, Member::currentUser());
151
        $response = $this->get($url);
152
        $this->assertEquals(302, $response->getStatusCode());
153
        $comment = DataObject::get_by_id(Comment::class, $comment->ID);
154
155
        // Need to use 0,1 here instead of false, true for SQLite
156
        $this->assertEquals(1, $comment->IsSpam);
157
        $this->assertEquals(1, $comment->Moderated);
158
159
        // try and spam a non existent comment
160
        $response = $this->get('comments/spam/100000');
161
        $this->assertEquals(404, $response->getStatusCode());
162
    }
163
164
    public function testRSS()
165
    {