本文整理匯總了PHP中WikiPage::doRollback方法的典型用法代碼示例。如果您正苦於以下問題:PHP WikiPage::doRollback方法的具體用法?PHP WikiPage::doRollback怎麽用?PHP WikiPage::doRollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WikiPage
的用法示例。
在下文中一共展示了WikiPage::doRollback方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doRollback
/**
* @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);
}
示例2: doRollback
/**
* @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);
}
示例3: testDoRollbackFailureSameContent
/**
* @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());
}
示例4: testDoRollback
/**
* @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());
}