Pass phpcs-strict on some test files (4/x)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 12:50:36 +0000 (14:50 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 16:51:42 +0000 (18:51 +0200)
Change-Id: Ifdbb431a6018c514b15ae71cc0c21b653a5e466d

12 files changed:
tests/phpunit/includes/StatusTest.php
tests/phpunit/includes/TestUser.php
tests/phpunit/includes/TitleArrayFromResultTest.php
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/TitleTest.php
tests/phpunit/includes/UserArrayFromResultTest.php
tests/phpunit/includes/UserTest.php
tests/phpunit/includes/WebRequestTest.php
tests/phpunit/includes/WikiPageTest.php
tests/phpunit/includes/WikiPageTestContentHandlerUseDB.php [new file with mode: 0644]
tests/phpunit/includes/WikiPageTest_ContentHandlerUseDB.php [deleted file]
tests/phpunit/includes/XmlSelectTest.php

index 8281073..1a6cfe6 100644 (file)
@@ -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() );
index 7d18206..610a6ac 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Wraps the user object, so we can also retain full access to properties like password if we log in via the API
+ * Wraps the user object, so we can also retain full access to properties
+ * like password if we log in via the API.
  */
 class TestUser {
        public $username;
@@ -10,7 +11,9 @@ class TestUser {
        public $groups;
        public $user;
 
-       public function __construct( $username, $realname = 'Real Name', $email = 'sample@example.com', $groups = array() ) {
+       public function __construct( $username, $realname = 'Real Name',
+               $email = 'sample@example.com', $groups = array()
+       ) {
                $this->username = $username;
                $this->realname = $realname;
                $this->email = $email;
index 832316e..e4c7623 100644 (file)
@@ -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() );
        }
 
index c7cbc7b..ac80a9a 100644 (file)
@@ -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 ) );
index e86b556..58d5eda 100644 (file)
@@ -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
index 8d095d6..ea44f36 100644 (file)
@@ -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() );
        }
 
index e6af126..a19d035 100644 (file)
@@ -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'
+               );
        }
 
        /**
index 06ed1fd..45fe3e9 100644 (file)
@@ -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'
+                       ),
                );
        }
 
index 9470359..37f1975 100644 (file)
@@ -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 (file)
index 0000000..3db7628
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @group ContentHandler
+ * @group Database
+ * ^--- important, causes temporary tables to be used instead of the real database
+ */
+class WikiPageTestContentHandlerUseDB extends WikiPageTest {
+
+       protected function setUp() {
+               parent::setUp();
+               $this->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 (file)
index 2a723e8..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-/**
- * @group ContentHandler
- * @group Database
- * ^--- important, causes temporary tables to be used instead of the real database
- */
-class WikiPageTest_ContentHandlerUseDB extends WikiPageTest {
-
-       protected function setUp() {
-               parent::setUp();
-               $this->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() ) );
-       }
-}
index 56d28b5..9f154bb 100644 (file)
@@ -72,7 +72,10 @@ class XmlSelectTest extends MediaWikiTestCase {
         */
        public function testAddOption() {
                $this->select->addOption( 'foo' );
-               $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
+               $this->assertEquals(
+                       '<select><option value="foo">foo</option></select>',
+                       $this->select->getHTML()
+               );
        }
 
        /**
@@ -80,7 +83,10 @@ class XmlSelectTest extends MediaWikiTestCase {
         */
        public function testAddOptionWithDefault() {
                $this->select->addOption( 'foo', true );
-               $this->assertEquals( '<select><option value="1">foo</option></select>', $this->select->getHTML() );
+               $this->assertEquals(
+                       '<select><option value="1">foo</option></select>',
+                       $this->select->getHTML()
+               );
        }
 
        /**
@@ -88,7 +94,10 @@ class XmlSelectTest extends MediaWikiTestCase {
         */
        public function testAddOptionWithFalse() {
                $this->select->addOption( 'foo', false );
-               $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
+               $this->assertEquals(
+                       '<select><option value="foo">foo</option></select>',
+                       $this->select->getHTML()
+               );
        }
 
        /**
@@ -96,7 +105,10 @@ class XmlSelectTest extends MediaWikiTestCase {
         */
        public function testAddOptionWithValueZero() {
                $this->select->addOption( 'foo', 0 );
-               $this->assertEquals( '<select><option value="0">foo</option></select>', $this->select->getHTML() );
+               $this->assertEquals(
+                       '<select><option value="0">foo</option></select>',
+                       $this->select->getHTML()
+               );
        }
 
        /**