function testMarkAsSpamLink()
 {
     $this->logInWithPermission("ADMIN");
     $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
     $forum = $spampost->Forum();
     $author = $spampost->Author();
     $link = $forum->AbsoluteLink("markasspam") . '/' . $spampost->ID;
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spampost->ID));
     // removes the post
     $this->assertFalse(DataObject::get_by_id('Post', $spampost->ID));
     // removes the member
     $this->assertFalse(DataObject::get_by_id('Member', $author->ID));
     // does not effect the thread
     $thread = DataObject::get_by_id('ForumThread', $spampost->Thread()->ID);
     $this->assertEquals('1', $thread->getNumPosts());
     // mark the first post in that now as spam
     $spamfirst = $this->objFromFixture('Post', 'SpamFirstPost');
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spamfirst->ID));
     // removes the thread
     $this->assertFalse(DataObject::get_by_id('ForumThread', $spamfirst->Thread()->ID));
 }
Example #2
0
 /**
  * Note: See {@link testCanModerate()} for detailed permission tests.
  */
 function testMarkAsSpamLink()
 {
     $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
     $forum = $spampost->Forum();
     $author = $spampost->Author();
     $moderator = $this->objFromFixture('Member', 'moderator');
     // moderator for "general" forum
     // without a logged-in moderator
     $this->assertNull($spampost->MarkAsSpamLink(), 'Link not present by default');
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spampost->ID));
     $this->assertEquals(403, $response->getStatusCode());
     // with logged-in moderator
     $moderator->logIn();
     $this->assertNotNull($spampost->MarkAsSpamLink(), 'Link present for moderators on this forum');
     $this->assertNull($author->SuspendedUntil);
     $link = $forum->AbsoluteLink("markasspam") . '/' . $spampost->ID;
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spampost->ID));
     $this->assertFalse($response->isError());
     // removes the post
     $this->assertFalse(DataObject::get_by_id('Post', $spampost->ID));
     // suspends the member
     $author = DataObject::get_by_id('Member', $author->ID);
     $this->assertNotNull($author->SuspendedUntil);
     // does not effect the thread
     $thread = DataObject::get_by_id('ForumThread', $spampost->Thread()->ID);
     $this->assertEquals('1', $thread->getNumPosts());
     // mark the first post in that now as spam
     $spamfirst = $this->objFromFixture('Post', 'SpamFirstPost');
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'markasspam/' . $spamfirst->ID));
     // removes the thread
     $this->assertFalse(DataObject::get_by_id('ForumThread', $spamfirst->Thread()->ID));
 }
 function testGhostLink()
 {
     $spampost = $this->objFromFixture('Post', 'SpamSecondPost');
     $forum = $spampost->Forum();
     $author = $spampost->Author();
     $moderator = $this->objFromFixture('Member', 'moderator');
     // moderator for "general" forum
     // without a logged-in moderator
     $this->assertFalse($spampost->GhostLink(), 'Link not present by default');
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'ghost/' . $spampost->AuthorID), DataModel::inst());
     $this->assertEquals(403, $response->getStatusCode());
     // with logged-in moderator
     $moderator->logIn();
     $this->assertNotEquals(false, $spampost->GhostLink(), 'Link present for moderators on this forum');
     $c = new Forum_Controller($forum);
     $response = $c->handleRequest(new SS_HTTPRequest('GET', 'ghost/' . $spampost->AuthorID), DataModel::inst());
     $this->assertFalse($response->isError());
     // post isn't available anymore in normal queries. {@link ForumSpamPostExtension}
     $post = Post::get()->byId($spampost->ID);
     $this->assertNull($post);
     // user is banned
     $author = Member::get()->byId($author->ID);
     $this->assertTrue($author->IsGhost());
 }