$this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ) ) );
$this->setUserPerm( "" );
- $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ) );
+ $this->runGroupPermissions(
+ 'move',
+ array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) )
+ );
$this->setUser( 'anon' );
$this->setUserPerm( "move" );
$this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ) ) );
$this->setUserPerm( "" );
- $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ),
- array( array( 'movenotallowedfile' ), array( 'movenologintext' ) ) );
+ $this->runGroupPermissions(
+ 'move',
+ array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ),
+ array( array( 'movenotallowedfile' ), array( 'movenologintext' ) )
+ );
if ( $this->isWikitextNS( NS_MAIN ) ) {
//NOTE: some content models don't allow moving
$this->assertEquals( array(), $res );
$this->setUser( 'anon' );
- $check = array( 'edit' => array( array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
- array( array( 'badaccess-group0' ) ),
- array(), true ),
- 'protect' => array( array( array( 'badaccess-groups', "[[$prefix:Administrators|Administrators]]", 1 ), array( 'protect-cantedit' ) ),
+ $check = array(
+ 'edit' => array(
+ array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
+ array( array( 'badaccess-group0' ) ),
+ array(),
+ true
+ ),
+ 'protect' => array(
+ array( array(
+ 'badaccess-groups',
+ "[[$prefix:Administrators|Administrators]]", 1 ),
+ array( 'protect-cantedit'
+ ) ),
array( array( 'badaccess-group0' ), array( 'protect-cantedit' ) ),
- array( array( 'protect-cantedit' ) ), false ),
- '' => array( array(), array(), array(), true ) );
+ array( array( 'protect-cantedit' ) ),
+ false
+ ),
+ '' => array( array(), array(), array(), true )
+ );
foreach ( array( "edit", "protect", "" ) as $action ) {
$this->setUserPerm( null );
$this->setTitle( NS_MAIN, "test page" );
$this->setUserPerm( array( "edit", "bogus" ) );
- $this->title->mCascadeSources = array( Title::makeTitle( NS_MAIN, "Bogus" ), Title::makeTitle( NS_MAIN, "UnBogus" ) );
- $this->title->mCascadingRestrictions = array( "bogus" => array( 'bogus', "sysop", "protect", "" ) );
+ $this->title->mCascadeSources = array(
+ Title::makeTitle( NS_MAIN, "Bogus" ),
+ Title::makeTitle( NS_MAIN, "UnBogus" )
+ );
+ $this->title->mCascadingRestrictions = array(
+ "bogus" => array( 'bogus', "sysop", "protect", "" )
+ );
$this->assertEquals( false,
$this->title->userCan( 'bogus', $this->user ) );
$page = $this->newPage( "WikiPageTest_testDoEditContent" );
$title = $page->getTitle();
- $content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
+ $content = ContentHandler::makeContent(
+ "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
- $title, CONTENT_MODEL_WIKITEXT );
+ $title,
+ CONTENT_MODEL_WIKITEXT
+ );
$page->doEditContent( $content, "[[testing]] 1" );
$this->assertTrue( $content->equals( $retrieved ), 'retrieved content doesn\'t equal original' );
# ------------------------
- $content = ContentHandler::makeContent( "At vero eos et accusam et justo duo [[dolores]] et ea rebum. "
+ $content = ContentHandler::makeContent(
+ "At vero eos et accusam et justo duo [[dolores]] et ea rebum. "
. "Stet clita kasd [[gubergren]], no sea takimata sanctus est.",
- $title, CONTENT_MODEL_WIKITEXT );
+ $title,
+ CONTENT_MODEL_WIKITEXT
+ );
$page->doEditContent( $content, "testing 2" );
public function testDoQuickEditContent() {
global $wgUser;
- $page = $this->createPage( "WikiPageTest_testDoQuickEditContent", "original text", CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ "WikiPageTest_testDoQuickEditContent",
+ "original text",
+ CONTENT_MODEL_WIKITEXT
+ );
- $content = ContentHandler::makeContent( "quick text", $page->getTitle(), CONTENT_MODEL_WIKITEXT );
+ $content = ContentHandler::makeContent(
+ "quick text",
+ $page->getTitle(),
+ CONTENT_MODEL_WIKITEXT
+ );
$page->doQuickEditContent( $content, $wgUser, "testing q" );
# ---------------------
* @covers WikiPage::doDeleteArticle
*/
public function testDoDeleteArticle() {
- $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ "WikiPageTest_testDoDeleteArticle",
+ "[[original text]] foo",
+ CONTENT_MODEL_WIKITEXT
+ );
$id = $page->getId();
$page->doDeleteArticle( "testing deletion" );
- $this->assertFalse( $page->getTitle()->getArticleID() > 0, "Title object should now have page id 0" );
+ $this->assertFalse(
+ $page->getTitle()->getArticleID() > 0,
+ "Title object should now have page id 0"
+ );
$this->assertFalse( $page->getId() > 0, "WikiPage should now have page id 0" );
- $this->assertFalse( $page->exists(), "WikiPage::exists should return false after page was deleted" );
- $this->assertNull( $page->getContent(), "WikiPage::getContent should return null after page was deleted" );
- $this->assertFalse( $page->getText(), "WikiPage::getText should return false after page was deleted" );
+ $this->assertFalse(
+ $page->exists(),
+ "WikiPage::exists should return false after page was deleted"
+ );
+ $this->assertNull(
+ $page->getContent(),
+ "WikiPage::getContent should return null after page was deleted"
+ );
+ $this->assertFalse(
+ $page->getText(),
+ "WikiPage::getText should return false after page was deleted"
+ );
$t = Title::newFromText( $page->getTitle()->getPrefixedText() );
- $this->assertFalse( $t->exists(), "Title::exists should return false after page was deleted" );
+ $this->assertFalse(
+ $t->exists(),
+ "Title::exists should return false after page was deleted"
+ );
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
* @covers WikiPage::doDeleteUpdates
*/
public function testDoDeleteUpdates() {
- $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ "WikiPageTest_testDoDeleteArticle",
+ "[[original text]] foo",
+ CONTENT_MODEL_WIKITEXT
+ );
$id = $page->getId();
$page->doDeleteUpdates( $id );
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
- $page = $this->createPage( "WikiPageTest_testGetContentModel", "some text", CONTENT_MODEL_JAVASCRIPT );
+ $page = $this->createPage(
+ "WikiPageTest_testGetContentModel",
+ "some text",
+ CONTENT_MODEL_JAVASCRIPT
+ );
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $page->getContentModel() );
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
- $page = $this->createPage( "WikiPageTest_testGetContentHandler", "some text", CONTENT_MODEL_JAVASCRIPT );
+ $page = $this->createPage(
+ "WikiPageTest_testGetContentHandler",
+ "some text",
+ CONTENT_MODEL_JAVASCRIPT
+ );
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( 'JavaScriptContentHandler', get_class( $page->getContentHandler() ) );
public static function provideGetRedirectTarget() {
return array(
array( 'WikiPageTest_testGetRedirectTarget_1', CONTENT_MODEL_WIKITEXT, "hello world", null ),
- array( 'WikiPageTest_testGetRedirectTarget_2', CONTENT_MODEL_WIKITEXT, "#REDIRECT [[hello world]]", "Hello world" ),
+ array(
+ 'WikiPageTest_testGetRedirectTarget_2',
+ CONTENT_MODEL_WIKITEXT,
+ "#REDIRECT [[hello world]]",
+ "Hello world"
+ ),
);
}
$title = Title::newFromText( $title );
- if ( !$wgContentHandlerUseDB && $model && ContentHandler::getDefaultModelFor( $title ) != $model ) {
+ if ( !$wgContentHandlerUseDB
+ && $model
+ && ContentHandler::getDefaultModelFor( $title ) != $model
+ ) {
$this->markTestSkipped( "Can not use non-default content model $model for "
. $title->getPrefixedDBkey() . " with \$wgContentHandlerUseDB disabled." );
}
$v = $page->isCountable();
$w = $page->isCountable( $editInfo );
- $this->assertEquals( $expected, $v, "isCountable( null ) returned unexpected value " . var_export( $v, true )
- . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+ $this->assertEquals(
+ $expected,
+ $v,
+ "isCountable( null ) returned unexpected value " . var_export( $v, true )
+ . " instead of " . var_export( $expected, true )
+ . " in mode `$mode` for text \"$text\""
+ );
- $this->assertEquals( $expected, $w, "isCountable( \$editInfo ) returned unexpected value " . var_export( $v, true )
- . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+ $this->assertEquals(
+ $expected,
+ $w,
+ "isCountable( \$editInfo ) returned unexpected value " . var_export( $v, true )
+ . " instead of " . var_export( $expected, true )
+ . " in mode `$mode` for text \"$text\""
+ );
}
public static function provideGetParserOutput() {
$this->assertFalse( $po, "getParserOutput() shall return false for non-existing revisions." );
}
- static $sections =
+ public static $sections =
"Intro
* @dataProvider dataReplaceSection
* @covers WikiPage::replaceSection
*/
- public function testReplaceSection( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
+ public function testReplaceSection( $title, $model, $text, $section, $with,
+ $sectionTitle, $expected
+ ) {
$this->hideDeprecated( "WikiPage::replaceSection" );
$page = $this->createPage( $title, $text, $model );
* @dataProvider dataReplaceSection
* @covers WikiPage::replaceSectionContent
*/
- public function testReplaceSectionContent( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
+ public function testReplaceSectionContent( $title, $model, $text, $section,
+ $with, $sectionTitle, $expected
+ ) {
$page = $this->createPage( $title, $text, $model );
$content = ContentHandler::makeContent( $with, $page->getTitle(), $page->getContentModel() );
$rev1 = $page->getRevision();
$text .= "\n\ntwo";
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section two");
+ $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section two"
+ );
$rev2 = $page->getRevision();
$text .= "\n\nthree";
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section three");
+ $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section three"
+ );
$rev3 = $page->getRevision();
$text .= "\n\nfour";
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section four");
+ $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section four"
+ );
$rev4 = $page->getRevision();
$text .= "\n\nfive";
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section five");
+ $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section five"
+ );
$rev5 = $page->getRevision();
$text .= "\n\nsix";
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section six");
+ $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle() ),
+ "adding section six"
+ );
$rev6 = $page->getRevision();
$undo6 = $page->getUndoText( $rev6 );
*/
/**
- * @todo FIXME: this is a better rollback test than the one below, but it keeps failing in jenkins for some reason.
+ * @todo FIXME: this is a better rollback test than the one below, but it
+ * keeps failing in jenkins for some reason.
*/
public function broken_testDoRollback() {
$admin = new User();
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
"adding section three", 0, false, $user2 );
- # we are having issues with doRollback spuriously failing. apparently the last revision somehow goes missing
- # or not committed under some circumstances. so, make sure the last revision has the right user name.
+ # we are having issues with doRollback spuriously failing. Apparently
+ # the last revision somehow goes missing or not committed under some
+ # circumstances. So, make sure the last revision has the right user name.
$dbr = wfGetDB( DB_SLAVE );
$this->assertEquals( 3, Revision::countByPageId( $dbr, $page->getId() ) );
# now, try the actual rollback
$admin->addGroup( "sysop" ); #XXX: make the test user a sysop...
- $token = $admin->getEditToken( array( $page->getTitle()->getPrefixedText(), $user2->getName() ), null );
- $errors = $page->doRollback( $user2->getName(), "testing revert", $token, false, $details, $admin );
+ $token = $admin->getEditToken(
+ array( $page->getTitle()->getPrefixedText(), $user2->getName() ),
+ null
+ );
+ $errors = $page->doRollback(
+ $user2->getName(),
+ "testing revert",
+ $token,
+ false,
+ $details,
+ $admin
+ );
if ( $errors ) {
- $this->fail( "Rollback failed:\n" . print_r( $errors, true ) . ";\n" . print_r( $details, true ) );
+ $this->fail( "Rollback failed:\n" . print_r( $errors, true )
+ . ";\n" . print_r( $details, true ) );
}
$page = new WikiPage( $page->getTitle() );
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
- "section one", EDIT_NEW, false, $admin );
+ $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 );
+ $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 );
+ $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 ) );
+ $this->fail( "Rollback failed:\n" . print_r( $errors, true )
+ . ";\n" . print_r( $details, true ) );
}
$page = new WikiPage( $page->getTitle() );
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
- "section one", EDIT_NEW, false, $admin );
+ $page->doEditContent(
+ ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+ "section one",
+ EDIT_NEW,
+ false,
+ $admin
+ );
$rev1 = $page->getRevision();
$user1 = new User();
$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 );
+ $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 );
+ $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 );
+ $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" );
),
array(
- 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
- labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et
- ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
+ 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
+ eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
+ voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
+ clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
'Hello world!',
0,
'/^Replaced .*Hello/'
array(
array(
- array( "first edit: "
- . "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
- . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. "
- . "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea "
- . "takimata sanctus est Lorem ipsum dolor sit amet.'", null ),
+ array(
+ "first edit: "
+ . "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
+ . " nonumy eirmod tempor invidunt ut labore et dolore magna "
+ . "aliquyam erat, sed diam voluptua. At vero eos et accusam "
+ . "et justo duo dolores et ea rebum. Stet clita kasd gubergren, "
+ . "no sea takimata sanctus est Lorem ipsum dolor sit amet.'",
+ null
+ ),
),
'/first edit:.*\.\.\."/',
false