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