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]); }