From: Siebrand Mazeland Date: Thu, 24 Apr 2014 12:50:36 +0000 (+0200) Subject: Pass phpcs-strict on some test files (4/x) X-Git-Tag: 1.31.0-rc.0~16034 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=4916e08d8ec075f0abb2af9191ab1c8318c79d2a;p=lhc%2Fweb%2Fwiklou.git Pass phpcs-strict on some test files (4/x) Change-Id: Ifdbb431a6018c514b15ae71cc0c21b653a5e466d --- diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php index 8281073083..1a6cfe6faf 100644 --- a/tests/phpunit/includes/StatusTest.php +++ b/tests/phpunit/includes/StatusTest.php @@ -233,7 +233,10 @@ class StatusTest extends MediaWikiLangTestCase { $status2->error( $message2 ); $status1->merge( $status2 ); - $this->assertEquals( 2, count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() ) ); + $this->assertEquals( + 2, + count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() ) + ); } /** @@ -249,7 +252,10 @@ class StatusTest extends MediaWikiLangTestCase { $status2->value = 'FooValue'; $status1->merge( $status2, true ); - $this->assertEquals( 2, count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() ) ); + $this->assertEquals( + 2, + count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() ) + ); $this->assertEquals( 'FooValue', $status1->getValue() ); } @@ -305,8 +311,9 @@ class StatusTest extends MediaWikiLangTestCase { * @dataProvider provideGetWikiTextAndHtml * @covers Status::getHtml * @todo test long and short context messages generated through this method - * this can not really be done now due to use of $this->getWikiText using wfMessage()->plain() - * It is possible to mock such methods but only if namespaces are used + * this can not really be done now due to use of $this->getWikiText using + * wfMessage()->plain(). It is possible to mock such methods but only if + * namespaces are used. */ public function testGetHtml( Status $status, $wikitext, $html ) { $this->assertEquals( $html, $status->getHTML() ); diff --git a/tests/phpunit/includes/TestUser.php b/tests/phpunit/includes/TestUser.php index 7d182065de..610a6acdc8 100644 --- a/tests/phpunit/includes/TestUser.php +++ b/tests/phpunit/includes/TestUser.php @@ -1,7 +1,8 @@ username = $username; $this->realname = $realname; $this->email = $email; diff --git a/tests/phpunit/includes/TitleArrayFromResultTest.php b/tests/phpunit/includes/TitleArrayFromResultTest.php index 832316ee18..e4c7623c80 100644 --- a/tests/phpunit/includes/TitleArrayFromResultTest.php +++ b/tests/phpunit/includes/TitleArrayFromResultTest.php @@ -77,7 +77,10 @@ class TitleArrayFromResultTest extends MediaWikiTestCase { * @covers TitleArrayFromResult::count */ public function testCountWithVaryingValues( $numRows ) { - $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( $this->getRowWithTitle(), $numRows ) ); + $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( + $this->getRowWithTitle(), + $numRows + ) ); $this->assertEquals( $numRows, $object->count() ); } diff --git a/tests/phpunit/includes/TitlePermissionTest.php b/tests/phpunit/includes/TitlePermissionTest.php index c7cbc7bdf4..ac80a9aa37 100644 --- a/tests/phpunit/includes/TitlePermissionTest.php +++ b/tests/phpunit/includes/TitlePermissionTest.php @@ -228,15 +228,21 @@ class TitlePermissionTest extends MediaWikiLangTestCase { $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 @@ -293,13 +299,25 @@ class TitlePermissionTest extends MediaWikiLangTestCase { $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 ); @@ -599,8 +617,13 @@ class TitlePermissionTest extends MediaWikiLangTestCase { $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 ) ); diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index e86b5565e8..58d5edab02 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -29,9 +29,15 @@ class TitleTest extends MediaWikiTestCase { foreach ( range( 1, 255 ) as $num ) { $chr = chr( $num ); if ( strpos( "#[]{}<>|", $chr ) !== false || preg_match( "/[\\x00-\\x1f\\x7f]/", $chr ) ) { - $this->assertFalse( (bool)preg_match( "/[$titlechars]/", $chr ), "chr($num) = $chr is not a valid titlechar" ); + $this->assertFalse( + (bool)preg_match( "/[$titlechars]/", $chr ), + "chr($num) = $chr is not a valid titlechar" + ); } else { - $this->assertTrue( (bool)preg_match( "/[$titlechars]/", $chr ), "chr($num) = $chr is a valid titlechar" ); + $this->assertTrue( + (bool)preg_match( "/[$titlechars]/", $chr ), + "chr($num) = $chr is a valid titlechar" + ); } } } @@ -231,7 +237,11 @@ class TitleTest extends MediaWikiTestCase { } else { $par = null; } - $this->assertEquals( $expectedParam, $par, "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter" ); + $this->assertEquals( + $expectedParam, + $par, + "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter" + ); } public static function provideBug31100() { @@ -332,7 +342,11 @@ class TitleTest extends MediaWikiTestCase { $allowableness = $expected ? " should be allowed" : " should NOT be allowed"; - $this->assertEquals( $expected, $errors, "User action '$action' on [[$source]] $allowableness." ); + $this->assertEquals( + $expected, + $errors, + "User action '$action' on [[$source]] $allowableness." + ); } else { $errors = $this->flattenErrorsArray( $errors ); foreach ( (array)$expected as $error ) { @@ -400,7 +414,9 @@ class TitleTest extends MediaWikiTestCase { * @dataProvider provideGetPageViewLanguage * @covers Title::getPageViewLanguage */ - public function testGetPageViewLanguage( $expected, $titleText, $contLang, $lang, $variant, $msg = '' ) { + public function testGetPageViewLanguage( $expected, $titleText, $contLang, + $lang, $variant, $msg = '' + ) { global $wgLanguageCode, $wgContLang, $wgLang, $wgDefaultLanguageVariant, $wgAllowUserJs; // Setup environnement for this test diff --git a/tests/phpunit/includes/UserArrayFromResultTest.php b/tests/phpunit/includes/UserArrayFromResultTest.php index 8d095d63c0..ea44f360f5 100644 --- a/tests/phpunit/includes/UserArrayFromResultTest.php +++ b/tests/phpunit/includes/UserArrayFromResultTest.php @@ -74,7 +74,10 @@ class UserArrayFromResultTest extends MediaWikiTestCase { * @covers UserArrayFromResult::count */ public function testCountWithVaryingValues( $numRows ) { - $object = $this->getUserArrayFromResult( $this->getMockResultWrapper( $this->getRowWithUsername(), $numRows ) ); + $object = $this->getUserArrayFromResult( $this->getMockResultWrapper( + $this->getRowWithUsername(), + $numRows + ) ); $this->assertEquals( $numRows, $object->count() ); } diff --git a/tests/phpunit/includes/UserTest.php b/tests/phpunit/includes/UserTest.php index e6af1264fc..a19d035baf 100644 --- a/tests/phpunit/includes/UserTest.php +++ b/tests/phpunit/includes/UserTest.php @@ -196,13 +196,21 @@ class UserTest extends MediaWikiTestCase { } $user->clearInstanceCache(); - $this->assertEquals( 3, $user->getEditCount(), 'After three edits, the user edit count should be 3' ); + $this->assertEquals( + 3, + $user->getEditCount(), + 'After three edits, the user edit count should be 3' + ); // increase the edit count and clear the cache $user->incEditCount(); $user->clearInstanceCache(); - $this->assertEquals( 4, $user->getEditCount(), 'After increasing the edit count manually, the user edit count should be 4' ); + $this->assertEquals( + 4, + $user->getEditCount(), + 'After increasing the edit count manually, the user edit count should be 4' + ); } /** diff --git a/tests/phpunit/includes/WebRequestTest.php b/tests/phpunit/includes/WebRequestTest.php index 06ed1fd20e..45fe3e9677 100644 --- a/tests/phpunit/includes/WebRequestTest.php +++ b/tests/phpunit/includes/WebRequestTest.php @@ -317,14 +317,30 @@ class WebRequestTest extends MediaWikiTestCase { array( '', array(), 'Empty Accept-Language header' ), array( 'en', array( 'en' => 1 ), 'One language' ), array( 'en, ar', array( 'en' => 1, 'ar' => 1 ), 'Two languages listed in appearance order.' ), - array( 'zh-cn,zh-tw', array( 'zh-cn' => 1, 'zh-tw' => 1 ), 'Two equally prefered languages, listed in appearance order per rfc3282. Checks c9119' ), - array( 'es, en; q=0.5', array( 'es' => 1, 'en' => '0.5' ), 'Spanish as first language and English and second' ), + array( + 'zh-cn,zh-tw', + array( 'zh-cn' => 1, 'zh-tw' => 1 ), + 'Two equally prefered languages, listed in appearance order per rfc3282. Checks c9119' + ), + array( + 'es, en; q=0.5', + array( 'es' => 1, 'en' => '0.5' ), + 'Spanish as first language and English and second' + ), array( 'en; q=0.5, es', array( 'es' => 1, 'en' => '0.5' ), 'Less prefered language first' ), array( 'fr, en; q=0.5, es', array( 'fr' => 1, 'es' => 1, 'en' => '0.5' ), 'Three languages' ), array( 'en; q=0.5, es', array( 'es' => 1, 'en' => '0.5' ), 'Two languages' ), array( 'en, zh;q=0', array( 'en' => 1 ), "It's Chinese to me" ), - array( 'es; q=1, pt;q=0.7, it; q=0.6, de; q=0.1, ru;q=0', array( 'es' => '1', 'pt' => '0.7', 'it' => '0.6', 'de' => '0.1' ), 'Preference for romance languages' ), - array( 'en-gb, en-us; q=1', array( 'en-gb' => 1, 'en-us' => '1' ), 'Two equally prefered English variants' ), + array( + 'es; q=1, pt;q=0.7, it; q=0.6, de; q=0.1, ru;q=0', + array( 'es' => '1', 'pt' => '0.7', 'it' => '0.6', 'de' => '0.1' ), + 'Preference for Romance languages' + ), + array( + 'en-gb, en-us; q=1', + array( 'en-gb' => 1, 'en-us' => '1' ), + 'Two equally prefered English variants' + ), ); } diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php index 9470359f0b..37f197515b 100644 --- a/tests/phpunit/includes/WikiPageTest.php +++ b/tests/phpunit/includes/WikiPageTest.php @@ -97,9 +97,12 @@ class WikiPageTest extends MediaWikiLangTestCase { $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" ); @@ -125,9 +128,12 @@ class WikiPageTest extends MediaWikiLangTestCase { $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" ); @@ -231,9 +237,17 @@ class WikiPageTest extends MediaWikiLangTestCase { 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" ); # --------------------- @@ -245,19 +259,38 @@ class WikiPageTest extends MediaWikiLangTestCase { * @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 ); @@ -272,7 +305,11 @@ class WikiPageTest extends MediaWikiLangTestCase { * @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 ); @@ -366,7 +403,11 @@ class WikiPageTest extends MediaWikiLangTestCase { $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() ); @@ -382,7 +423,11 @@ class WikiPageTest extends MediaWikiLangTestCase { $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() ) ); @@ -440,7 +485,12 @@ class WikiPageTest extends MediaWikiLangTestCase { 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" + ), ); } @@ -587,7 +637,10 @@ class WikiPageTest extends MediaWikiLangTestCase { $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." ); } @@ -599,11 +652,21 @@ class WikiPageTest extends MediaWikiLangTestCase { $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() { @@ -661,7 +724,7 @@ class WikiPageTest extends MediaWikiLangTestCase { $this->assertFalse( $po, "getParserOutput() shall return false for non-existing revisions." ); } - static $sections = + public static $sections = "Intro @@ -727,7 +790,9 @@ more stuff * @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 ); @@ -741,7 +806,9 @@ more stuff * @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() ); @@ -759,23 +826,38 @@ more stuff $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 ); @@ -793,7 +875,8 @@ more stuff */ /** - * @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(); @@ -818,8 +901,9 @@ more stuff $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() ) ); @@ -835,11 +919,22 @@ more stuff # 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() ); @@ -858,24 +953,45 @@ more stuff $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() ); @@ -894,8 +1010,13 @@ more stuff $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(); @@ -903,20 +1024,45 @@ more stuff $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" ); @@ -951,9 +1097,10 @@ more stuff ), 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/' @@ -1019,11 +1166,15 @@ more stuff 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 diff --git a/tests/phpunit/includes/WikiPageTestContentHandlerUseDB.php b/tests/phpunit/includes/WikiPageTestContentHandlerUseDB.php new file mode 100644 index 0000000000..3db7628090 --- /dev/null +++ b/tests/phpunit/includes/WikiPageTestContentHandlerUseDB.php @@ -0,0 +1,61 @@ +setMwGlobals( 'wgContentHandlerUseDB', false ); + + $dbw = wfGetDB( DB_MASTER ); + + $page_table = $dbw->tableName( 'page' ); + $revision_table = $dbw->tableName( 'revision' ); + $archive_table = $dbw->tableName( 'archive' ); + + if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) { + $dbw->query( "alter table $page_table drop column page_content_model" ); + $dbw->query( "alter table $revision_table drop column rev_content_model" ); + $dbw->query( "alter table $revision_table drop column rev_content_format" ); + $dbw->query( "alter table $archive_table drop column ar_content_model" ); + $dbw->query( "alter table $archive_table drop column ar_content_format" ); + } + } + + /** + * @covers WikiPage::getContentModel + */ + public function testGetContentModel() { + $page = $this->createPage( + "WikiPageTest_testGetContentModel", + "some text", + CONTENT_MODEL_JAVASCRIPT + ); + + $page = new WikiPage( $page->getTitle() ); + + // NOTE: since the content model is not recorded in the database, + // we expect to get the default, namely CONTENT_MODEL_WIKITEXT + $this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() ); + } + + /** + * @covers WikiPage::getContentHandler + */ + public function testGetContentHandler() { + $page = $this->createPage( + "WikiPageTest_testGetContentHandler", + "some text", + CONTENT_MODEL_JAVASCRIPT + ); + + // NOTE: since the content model is not recorded in the database, + // we expect to get the default, namely CONTENT_MODEL_WIKITEXT + $page = new WikiPage( $page->getTitle() ); + $this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) ); + } +} diff --git a/tests/phpunit/includes/WikiPageTest_ContentHandlerUseDB.php b/tests/phpunit/includes/WikiPageTest_ContentHandlerUseDB.php deleted file mode 100644 index 2a723e8503..0000000000 --- a/tests/phpunit/includes/WikiPageTest_ContentHandlerUseDB.php +++ /dev/null @@ -1,53 +0,0 @@ -setMwGlobals( 'wgContentHandlerUseDB', false ); - - $dbw = wfGetDB( DB_MASTER ); - - $page_table = $dbw->tableName( 'page' ); - $revision_table = $dbw->tableName( 'revision' ); - $archive_table = $dbw->tableName( 'archive' ); - - if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) { - $dbw->query( "alter table $page_table drop column page_content_model" ); - $dbw->query( "alter table $revision_table drop column rev_content_model" ); - $dbw->query( "alter table $revision_table drop column rev_content_format" ); - $dbw->query( "alter table $archive_table drop column ar_content_model" ); - $dbw->query( "alter table $archive_table drop column ar_content_format" ); - } - } - - /** - * @covers WikiPage::getContentModel - */ - public function testGetContentModel() { - $page = $this->createPage( "WikiPageTest_testGetContentModel", "some text", CONTENT_MODEL_JAVASCRIPT ); - - $page = new WikiPage( $page->getTitle() ); - - // NOTE: since the content model is not recorded in the database, - // we expect to get the default, namely CONTENT_MODEL_WIKITEXT - $this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() ); - } - - /** - * @covers WikiPage::getContentHandler - */ - public function testGetContentHandler() { - $page = $this->createPage( "WikiPageTest_testGetContentHandler", "some text", CONTENT_MODEL_JAVASCRIPT ); - - // NOTE: since the content model is not recorded in the database, - // we expect to get the default, namely CONTENT_MODEL_WIKITEXT - $page = new WikiPage( $page->getTitle() ); - $this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) ); - } -} diff --git a/tests/phpunit/includes/XmlSelectTest.php b/tests/phpunit/includes/XmlSelectTest.php index 56d28b5411..9f154bb758 100644 --- a/tests/phpunit/includes/XmlSelectTest.php +++ b/tests/phpunit/includes/XmlSelectTest.php @@ -72,7 +72,10 @@ class XmlSelectTest extends MediaWikiTestCase { */ public function testAddOption() { $this->select->addOption( 'foo' ); - $this->assertEquals( '', $this->select->getHTML() ); + $this->assertEquals( + '', + $this->select->getHTML() + ); } /** @@ -80,7 +83,10 @@ class XmlSelectTest extends MediaWikiTestCase { */ public function testAddOptionWithDefault() { $this->select->addOption( 'foo', true ); - $this->assertEquals( '', $this->select->getHTML() ); + $this->assertEquals( + '', + $this->select->getHTML() + ); } /** @@ -88,7 +94,10 @@ class XmlSelectTest extends MediaWikiTestCase { */ public function testAddOptionWithFalse() { $this->select->addOption( 'foo', false ); - $this->assertEquals( '', $this->select->getHTML() ); + $this->assertEquals( + '', + $this->select->getHTML() + ); } /** @@ -96,7 +105,10 @@ class XmlSelectTest extends MediaWikiTestCase { */ public function testAddOptionWithValueZero() { $this->select->addOption( 'foo', 0 ); - $this->assertEquals( '', $this->select->getHTML() ); + $this->assertEquals( + '', + $this->select->getHTML() + ); } /**