|
@@ 89-111 (lines=23) @@
|
| 86 |
|
$this->assertNull($commController->getOwnerController()); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
public function testHam() |
| 90 |
|
{ |
| 91 |
|
SecurityToken::inst()->disable(); |
| 92 |
|
|
| 93 |
|
// mark a comment as spam then ham it |
| 94 |
|
$this->logInWithPermission('CMS_ACCESS_CommentAdmin'); |
| 95 |
|
$comment = $this->objFromFixture(Comment::class, 'firstComA'); |
| 96 |
|
$comment->markSpam(); |
| 97 |
|
$st = new CommentSecurityToken($comment); |
| 98 |
|
$url = 'comments/ham/' . $comment->ID; |
| 99 |
|
$url = $st->addToUrl($url, Member::currentUser()); |
| 100 |
|
$response = $this->get($url); |
| 101 |
|
$this->assertEquals(302, $response->getStatusCode()); |
| 102 |
|
$comment = DataObject::get_by_id(Comment::class, $comment->ID); |
| 103 |
|
|
| 104 |
|
// Need to use 0,1 here instead of false, true for SQLite |
| 105 |
|
$this->assertEquals(0, $comment->IsSpam); |
| 106 |
|
$this->assertEquals(1, $comment->Moderated); |
| 107 |
|
|
| 108 |
|
// try and ham a non existent comment |
| 109 |
|
$response = $this->get('comments/ham/100000'); |
| 110 |
|
$this->assertEquals(404, $response->getStatusCode()); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
public function testSpam() |
| 114 |
|
{ |
|
@@ 113-133 (lines=21) @@
|
| 110 |
|
$this->assertEquals(404, $response->getStatusCode()); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
public function testSpam() |
| 114 |
|
{ |
| 115 |
|
// mark a comment as approved then spam it |
| 116 |
|
$this->logInWithPermission('CMS_ACCESS_CommentAdmin'); |
| 117 |
|
$comment = $this->objFromFixture(Comment::class, 'firstComA'); |
| 118 |
|
$comment->markApproved(); |
| 119 |
|
$st = new CommentSecurityToken($comment); |
| 120 |
|
$url = 'comments/spam/' . $comment->ID; |
| 121 |
|
$url = $st->addToUrl($url, Member::currentUser()); |
| 122 |
|
$response = $this->get($url); |
| 123 |
|
$this->assertEquals(302, $response->getStatusCode()); |
| 124 |
|
$comment = DataObject::get_by_id(Comment::class, $comment->ID); |
| 125 |
|
|
| 126 |
|
// Need to use 0,1 here instead of false, true for SQLite |
| 127 |
|
$this->assertEquals(1, $comment->IsSpam); |
| 128 |
|
$this->assertEquals(1, $comment->Moderated); |
| 129 |
|
|
| 130 |
|
// try and spam a non existent comment |
| 131 |
|
$response = $this->get('comments/spam/100000'); |
| 132 |
|
$this->assertEquals(404, $response->getStatusCode()); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
public function testRSS() |
| 136 |
|
{ |