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]); }
public function testApproveAllConflicts() { $t = new ModerationTestsuite(); $t->doNTestEditsWith($t->unprivilegedUser, null, 'Page A'); $this->makeEditConflict($t); $t->doNTestEditsWith($t->unprivilegedUser, null, 'Page B'); # Will attempt to ApproveAll the edit by $t->unprivilegedUser # cause an edit conflict? $t->fetchSpecial(); $t->html->loadFromURL($t->new_entries[0]->approveAllLink); $text = $t->html->getMainText(); $this->assertRegExp('/\\(moderation-approved-ok: ' . $t->TEST_EDITS_COUNT * 2 . '\\)/', $text, "testApproveAllConflicts(): Result page doesn't contain (moderation-approved-ok: N)"); $this->assertRegExp('/\\(moderation-approved-errors: 1\\)/', $text, "testApproveAllConflicts(): Result page doesn't contain (moderation-approved-errors: 1)"); $t->assumeFolderIsEmpty(); $t->fetchSpecial(); $this->assertCount(1, $t->new_entries, "testApproveAllConflicts(): Nothing left in Pending folder after modaction=approveall, even though there was an edit conflict"); $this->assertTrue($t->new_entries[0]->conflict, "testApproveAllConflicts(): Edit with detected conflict is not marked with class='modconflict'"); }
public function testApproveAllNotRejected() { $t = new ModerationTestsuite(); $t->TEST_EDITS_COUNT = 10; $t->doNTestEditsWith($t->unprivilegedUser); $t->fetchSpecial(); # Already rejected edits must not be affected by ApproveAll. # So let's reject some edits and check... $approveAllLink = $t->new_entries[0]->approveAllLink; # Odd edits are rejected, even edits are approved. for ($i = 1; $i < $t->TEST_EDITS_COUNT; $i += 2) { $t->httpGet($t->new_entries[$i]->rejectLink); } $t->fetchSpecial('rejected'); $t->httpGet($approveAllLink, 'GET'); $t->fetchSpecial('rejected'); $this->assertCount(0, $t->new_entries, "testApproveAllNotRejected(): Something was added into Rejected folder during modaction=approveall"); $this->assertCount(0, $t->deleted_entries, "testApproveAllNotRejected(): Something was deleted from Rejected folder during modaction=approveall"); }