Ejemplo n.º 1
0
 /**
  * @param $fromP
  * @param $summary
  * @param $token
  * @param $bot
  * @param $resultDetails
  * @param $user User
  * @return array
  */
 public function doRollback($fromP, $summary, $token, $bot, &$resultDetails, User $user = null)
 {
     $user = is_null($user) ? $this->getContext()->getUser() : $user;
     return $this->mPage->doRollback($fromP, $summary, $token, $bot, $resultDetails, $user);
 }
Ejemplo n.º 2
0
 /**
  * @param $fromP
  * @param $summary
  * @param $token
  * @param $bot
  * @param $resultDetails
  * @param $user User
  * @return array
  */
 public function doRollback($fromP, $summary, $token, $bot, &$resultDetails, User $user = null)
 {
     global $wgUser;
     $user = is_null($user) ? $wgUser : $user;
     return $this->mPage->doRollback($fromP, $summary, $token, $bot, $resultDetails, $user);
 }
 /**
  * @covers WikiPage::doRollback
  */
 public function testDoRollbackFailureSameContent()
 {
     $admin = new User();
     $admin->setName("Admin");
     $admin->addGroup("sysop");
     #XXX: make the test user a sysop...
     $text = "one";
     $page = $this->newPage("WikiPageTest_testDoRollback");
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), CONTENT_MODEL_WIKITEXT), "section one", EDIT_NEW, false, $admin);
     $rev1 = $page->getRevision();
     $user1 = new User();
     $user1->setName("127.0.1.11");
     $user1->addGroup("sysop");
     #XXX: make the test user a sysop...
     $text .= "\n\ntwo";
     $page = new WikiPage($page->getTitle());
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), CONTENT_MODEL_WIKITEXT), "adding section two", 0, false, $user1);
     # now, do a the rollback from the same user was doing the edit before
     $resultDetails = array();
     $token = $user1->getEditToken(array($page->getTitle()->getPrefixedText(), $user1->getName()), null);
     $errors = $page->doRollback($user1->getName(), "testing revert same user", $token, false, $resultDetails, $admin);
     $this->assertEquals(array(), $errors, "Rollback failed same user");
     # now, try the rollback
     $resultDetails = array();
     $token = $admin->getEditToken(array($page->getTitle()->getPrefixedText(), $user1->getName()), null);
     $errors = $page->doRollback($user1->getName(), "testing revert", $token, false, $resultDetails, $admin);
     $this->assertEquals(array(array('alreadyrolled', 'WikiPageTest testDoRollback', '127.0.1.11', 'Admin')), $errors, "Rollback not failed");
     $page = new WikiPage($page->getTitle());
     $this->assertEquals($rev1->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision");
     $this->assertEquals("one", $page->getContent()->getNativeData());
 }
Ejemplo n.º 4
0
 /**
  * @todo FIXME: the above rollback test is better, but it keeps failing in jenkins for some reason.
  */
 public function testDoRollback()
 {
     $admin = new User();
     $admin->setName("Admin");
     $text = "one";
     $page = $this->newPage("WikiPageTest_testDoRollback");
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), CONTENT_MODEL_WIKITEXT), "section one", EDIT_NEW, false, $admin);
     $rev1 = $page->getRevision();
     $user1 = new User();
     $user1->setName("127.0.1.11");
     $text .= "\n\ntwo";
     $page = new WikiPage($page->getTitle());
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), CONTENT_MODEL_WIKITEXT), "adding section two", 0, false, $user1);
     # now, try the rollback
     $admin->addGroup("sysop");
     #XXX: make the test user a sysop...
     $token = $admin->getEditToken(array($page->getTitle()->getPrefixedText(), $user1->getName()), null);
     $errors = $page->doRollback($user1->getName(), "testing revert", $token, false, $details, $admin);
     if ($errors) {
         $this->fail("Rollback failed:\n" . print_r($errors, true) . ";\n" . print_r($details, true));
     }
     $page = new WikiPage($page->getTitle());
     $this->assertEquals($rev1->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision");
     $this->assertEquals("one", $page->getContent()->getNativeData());
 }