public function testModerationCheckuser() { $t = new ModerationTestsuite(); $entry = $t->getSampleEntry(); $this->assertNull($entry->ip, "testModerationCheckuser(): IP was shown to non-checkuser on Special:Moderation"); $t->moderator = $t->moderatorAndCheckuser; $t->assumeFolderIsEmpty(); $t->fetchSpecial(); $entry = $t->new_entries[0]; $this->assertNotNull($entry->ip, "testModerationCheckuser(): IP wasn't shown to checkuser on Special:Moderation"); $this->assertEquals("127.0.0.1", $entry->ip, "testModerationCheckuser(): incorrect IP on Special:Moderation"); }
public function testApproveNotExpiredRejected() { global $wgModerationTimeToOverrideRejection; $t = new ModerationTestsuite(); # Rejected edits can only be approved if they are no older # than $wgModerationTimeToOverrideRejection. $t->loginAs($t->unprivilegedUser); $t->doTestEdit(); $t->fetchSpecial(); $id = $t->new_entries[0]->id; $t->httpGet($t->new_entries[0]->rejectLink); /* Modify mod_timestamp to make this edit 1 hour older than allowed by $wgModerationTimeToOverrideRejection. */ $ts = new MWTimestamp(time()); $ts->timestamp->modify('-' . intval($wgModerationTimeToOverrideRejection) . ' seconds'); $ts->timestamp->modify('-1 hour'); /* Should NOT be approvable */ $dbw = wfGetDB(DB_MASTER); $dbw->update('moderation', array('mod_timestamp' => $ts->getTimestamp(TS_MW)), array('mod_id' => $id), __METHOD__); $t->fetchSpecial('rejected'); $entry = $t->new_entries[0]; $this->assertNull($entry->approveLink, "testApproveNotExpiredRejected(): Approve link found for edit that was rejected more than {$wgModerationTimeToOverrideRejection} seconds ago"); # Ensure that usual approve URL doesn't work: $error = $t->html->getModerationError($entry->expectedActionLink('approve')); $this->assertEquals('(moderation-rejected-long-ago)', $error, "testApproveNotExpiredRejected(): No expected error from modaction=approve"); /* Make the edit less ancient than $wgModerationTimeToOverrideRejection ago */ $ts->timestamp->modify('+2 hour'); /* Should be approvable */ $dbw = wfGetDB(DB_MASTER); $dbw->update('moderation', array('mod_timestamp' => $ts->getTimestamp(TS_MW)), array('mod_id' => $id), __METHOD__); $t->assumeFolderIsEmpty('rejected'); $t->fetchSpecial('rejected'); $entry = $t->new_entries[0]; $this->assertNotNull($entry->approveLink, "testApproveNotExpiredRejected(): Approve link is missing for edit that was rejected less than {$wgModerationTimeToOverrideRejection} seconds ago"); $this->tryToApprove($t, $entry); }