本文整理汇总了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());
}