public function testApproveAll() { $t = new ModerationTestsuite(); # We edit with two users: # $t->unprivilegedUser (A) # and $t->unprivilegedUser2 (B) # We're applying approveall to one of the edits by A. # Expected result is: # 1) All edits by A were approved, # 2) No edits by B were touched during approveall. $t->doNTestEditsWith($t->unprivilegedUser, $t->unprivilegedUser2); $t->fetchSpecial(); # Find edits by user A (they will be approved) $entries = ModerationTestsuiteEntry::findByUser($t->new_entries, $t->unprivilegedUser); $this->assertNotNull($entries[0]->approveAllLink, "testApproveAll(): ApproveAll link not found"); $t->html->loadFromURL($entries[0]->approveAllLink); $this->assertRegExp('/\\(moderation-approved-ok: ' . $t->TEST_EDITS_COUNT . '\\)/', $t->html->getMainText(), "testApproveAll(): Result page doesn't contain (moderation-approved-ok: N)"); $t->fetchSpecial(); $this->assertCount(0, $t->new_entries, "testApproveAll(): Something was added into Pending folder during modaction=approveall"); $this->assertCount($t->TEST_EDITS_COUNT, $t->deleted_entries, "testApproveAll(): Several edits were approved, but number of deleted entries in Pending folder doesn't match"); foreach ($entries as $entry) { $rev = $t->getLastRevision($entry->title); $this->assertEquals($t->unprivilegedUser->getName(), $rev['user']); } # Check the log entries: there should be # - one 'approveall' log entry # - TEST_EDITS_COUNT 'approve' log entries. $events = $t->apiLogEntries(); $this->assertCount(1 + $t->TEST_EDITS_COUNT, $events, "testApproveAll(): Number of log entries doesn't match the number of approved edits PLUS ONE (log entry for ApproveAll itself)."); # Per design, 'approveall' entry MUST be the most recent. $le = array_shift($events); $this->assertEquals('approveall', $le['action'], "testApproveAll(): Most recent log entry is not 'approveall'"); $this->assertEquals($t->moderator->getName(), $le['user']); $this->assertEquals($t->unprivilegedUser->getUserPage(), $le['title']); foreach ($events as $le) { $this->assertEquals('approve', $le['action']); $this->assertEquals($t->moderator->getName(), $le['user']); } # Only the formatting of 'approveall' line needs to be checked, # formatting of 'approve' lines already tested in testApprove() $events = $t->nonApiLogEntries(1); $this->assertEquals('approveall', $events[0]['type']); $this->assertEquals($t->moderator->getName(), $events[0]['params'][1]); $this->assertEquals($t->unprivilegedUser->getUserPage()->getText(), $events[0]['params'][2]); $this->assertEquals($t->TEST_EDITS_COUNT, $events[0]['params'][3]); }
public function testRejectAll() { $t = new ModerationTestsuite(); # We edit with two users: # $t->unprivilegedUser (A) # and $t->unprivilegedUser2 (B) # We're applying rejectall to one of the edits by A. # Expected result is: # 1) All edits by A were rejected, # 2) No edits by B were touched during rejectall. $t->doNTestEditsWith($t->unprivilegedUser, $t->unprivilegedUser2); $t->fetchSpecial(); # Find edits by user A (they will be rejected) $entries = ModerationTestsuiteEntry::findByUser($t->new_entries, $t->unprivilegedUser); $this->assertNotNull($entries[0]->rejectAllLink, "testRejectAll(): RejectAll link not found"); $t->html->loadFromURL($entries[0]->rejectAllLink); $this->assertRegExp('/\\(moderation-rejected-ok: ' . $t->TEST_EDITS_COUNT . '\\)/', $t->html->getMainText(), "testRejectAll(): Result page doesn't contain (moderation-rejected-ok: N)"); $t->fetchSpecial(); $this->assertCount(0, $t->new_entries, "testRejectAll(): Something was added into Pending folder during modaction=rejectall"); $this->assertCount($t->TEST_EDITS_COUNT, $t->deleted_entries, "testRejectAll(): Several edits were rejected, but number of deleted entries in Pending folder doesn't match"); foreach ($entries as $entry) { $de = ModerationTestsuiteEntry::findById($t->deleted_entries, $entry->id); $this->assertNotNull($de); $this->assertEquals($entry->user, $de->user); $this->assertEquals($entry->title, $de->title); } $t->fetchSpecial('rejected'); $this->assertCount($t->TEST_EDITS_COUNT, $t->new_entries, "testRejectAll(): Several edits were rejected, but number of new entries in Rejected folder doesn't match"); $this->assertCount(0, $t->deleted_entries, "testRejectAll(): Something was deleted from Rejected folder during modaction=rejectall"); foreach ($entries as $entry) { $de = ModerationTestsuiteEntry::findById($t->new_entries, $entry->id); $this->assertNotNull($de); $this->assertEquals($entry->user, $de->user); $this->assertEquals($entry->title, $de->title); $this->assertEquals($t->moderator->getName(), $de->rejected_by_user); $this->assertTrue($de->rejected_batch, "testRejectAll(): Edit rejected via modaction=rejectall has rejected_batch flag OFF"); $this->assertFalse($de->rejected_auto, "testRejectAll(): Manually rejected edit has rejected_auto flag ON"); $this->assertNull($de->rejectLink, "testRejectAll(): Reject link found for already rejected edit"); $this->assertNull($de->rejectAllLink, "testRejectAll(): RejectAll link found for already rejected edit"); $this->assertNull($de->approveAllLink, "testRejectAll(): ApproveAll link found for already rejected edit"); } # Check the log entry: there should be only one 'rejectall'. $events = $t->apiLogEntries(); $this->assertCount(1, $events, "testRejectAll(): Number of log entries isn't 1."); $le = $events[0]; $this->assertEquals('rejectall', $le['action'], "testRejectAll(): Most recent log entry is not 'rejectall'"); $this->assertEquals($t->moderator->getName(), $le['user']); $this->assertEquals($t->unprivilegedUser->getUserPage(), $le['title']); $this->assertEquals($t->TEST_EDITS_COUNT, $le['count']); $events = $t->nonApiLogEntries(1); $this->assertEquals('rejectall', $events[0]['type']); $this->assertEquals($t->moderator->getName(), $events[0]['params'][1]); $this->assertEquals($t->unprivilegedUser->getUserPage()->getText(), $events[0]['params'][2]); $this->assertEquals($t->TEST_EDITS_COUNT, $events[0]['params'][3]); }