Update formatting
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Feb 2013 11:56:23 +0000 (12:56 +0100)
committerSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Feb 2013 11:56:23 +0000 (12:56 +0100)
3 of n.

Change-Id: I62ad009018c54da6cf081c334e44eb98a3c72695

14 files changed:
tests/phpunit/includes/WikiPageTest.php
tests/phpunit/includes/XmlSelectTest.php
tests/phpunit/includes/XmlTest.php
tests/phpunit/includes/ZipDirectoryReaderTest.php
tests/phpunit/includes/api/ApiAccountCreationTest.php
tests/phpunit/includes/api/ApiBlockTest.php
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/includes/api/ApiGeneratorTest.php
tests/phpunit/includes/api/ApiParseTest.php
tests/phpunit/includes/api/ApiPurgeTest.php
tests/phpunit/includes/api/ApiTest.php
tests/phpunit/includes/api/ApiTestCase.php
tests/phpunit/includes/api/ApiTestCaseUpload.php
tests/phpunit/includes/api/ApiUploadTest.php

index 46e0f9d..2501be3 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 /**
-* @group ContentHandler
-* @group Database
-* ^--- important, causes temporary tables to be used instead of the real database
-* @group medium
-**/
+ * @group ContentHandler
+ * @group Database
+ * ^--- important, causes temporary tables to be used instead of the real database
+ * @group medium
+ **/
 
 class WikiPageTest extends MediaWikiLangTestCase {
 
@@ -13,23 +13,23 @@ class WikiPageTest extends MediaWikiLangTestCase {
        function  __construct( $name = null, array $data = array(), $dataName = '' ) {
                parent::__construct( $name, $data, $dataName );
 
-               $this->tablesUsed = array_merge (
+               $this->tablesUsed = array_merge(
                        $this->tablesUsed,
                        array( 'page',
-                                       'revision',
-                                       'text',
+                               'revision',
+                               'text',
 
-                                       'recentchanges',
-                                       'logging',
+                               'recentchanges',
+                               'logging',
 
-                                       'page_props',
-                                       'pagelinks',
-                                       'categorylinks',
-                                       'langlinks',
-                                       'externallinks',
-                                       'imagelinks',
-                                       'templatelinks',
-                                       'iwlinks' ) );
+                               'page_props',
+                               'pagelinks',
+                               'categorylinks',
+                               'langlinks',
+                               'externallinks',
+                               'imagelinks',
+                               'templatelinks',
+                               'iwlinks' ) );
        }
 
        protected function setUp() {
@@ -72,7 +72,6 @@ class WikiPageTest extends MediaWikiLangTestCase {
                return $p;
        }
 
-
        /**
         * @param String|Title|WikiPage $page
         * @param String $text
@@ -96,8 +95,8 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $title = $page->getTitle();
 
                $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 );
+                               . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+                       $title, CONTENT_MODEL_WIKITEXT );
 
                $page->doEditContent( $content, "[[testing]] 1" );
 
@@ -124,8 +123,8 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                # ------------------------
                $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 );
+                               . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.",
+                       $title, CONTENT_MODEL_WIKITEXT );
 
                $page->doEditContent( $content, "testing 2" );
 
@@ -155,7 +154,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $page = $this->newPage( $title );
 
                $text = "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
-                               . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.";
+                       . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.";
 
                $page->doEdit( $text, "[[testing]] 1" );
 
@@ -182,7 +181,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                # ------------------------
                $text = "At vero eos et accusam et justo duo [[dolores]] et ea rebum. "
-                               . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.";
+                       . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.";
 
                $page->doEdit( $text, "testing 2" );
 
@@ -433,104 +432,104 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                        // any
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       '',
-                                       'any',
-                                       true
+                               CONTENT_MODEL_WIKITEXT,
+                               '',
+                               'any',
+                               true
                        ),
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo',
-                                       'any',
-                                       true
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo',
+                               'any',
+                               true
                        ),
 
                        // comma
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo',
-                                       'comma',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo',
+                               'comma',
+                               false
                        ),
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo, bar',
-                                       'comma',
-                                       true
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo, bar',
+                               'comma',
+                               true
                        ),
 
                        // link
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo',
-                                       'link',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo',
+                               'link',
+                               false
                        ),
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo [[bar]]',
-                                       'link',
-                                       true
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo [[bar]]',
+                               'link',
+                               true
                        ),
 
                        // redirects
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       '#REDIRECT [[bar]]',
-                                       'any',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               '#REDIRECT [[bar]]',
+                               'any',
+                               false
                        ),
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       '#REDIRECT [[bar]]',
-                                       'comma',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               '#REDIRECT [[bar]]',
+                               'comma',
+                               false
                        ),
                        array( 'WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       '#REDIRECT [[bar]]',
-                                       'link',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               '#REDIRECT [[bar]]',
+                               'link',
+                               false
                        ),
 
                        // not a content namespace
                        array( 'Talk:WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo',
-                                       'any',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo',
+                               'any',
+                               false
                        ),
                        array( 'Talk:WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo, bar',
-                                       'comma',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo, bar',
+                               'comma',
+                               false
                        ),
                        array( 'Talk:WikiPageTest_testIsCountable',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       'Foo [[bar]]',
-                                       'link',
-                                       false
+                               CONTENT_MODEL_WIKITEXT,
+                               'Foo [[bar]]',
+                               'link',
+                               false
                        ),
 
                        // not a content namespace, different model
                        array( 'MediaWiki:WikiPageTest_testIsCountable.js',
-                                       null,
-                                       'Foo',
-                                       'any',
-                                       false
+                               null,
+                               'Foo',
+                               'any',
+                               false
                        ),
                        array( 'MediaWiki:WikiPageTest_testIsCountable.js',
-                                       null,
-                                       'Foo, bar',
-                                       'comma',
-                                       false
+                               null,
+                               'Foo, bar',
+                               'comma',
+                               false
                        ),
                        array( 'MediaWiki:WikiPageTest_testIsCountable.js',
-                                       null,
-                                       'Foo [[bar]]',
-                                       'link',
-                                       false
+                               null,
+                               'Foo [[bar]]',
+                               'link',
+                               false
                        ),
                );
        }
@@ -553,7 +552,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                $page = $this->createPage( $title, $text, $model );
                $hasLinks = wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
-                                       array( 'pl_from' => $page->getId() ), __METHOD__ );
+                       array( 'pl_from' => $page->getId() ), __METHOD__ );
 
                $editInfo = $page->prepareContentForEdit( $page->getContent() );
 
@@ -561,15 +560,15 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $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\"" );
+                       . " 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\"" );
+                       . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
        }
 
        public static function provideGetParserOutput() {
                return array(
-                       array( CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i></p>"),
+                       array( CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i></p>" ),
                        // @todo: more...?
                );
        }
@@ -591,9 +590,9 @@ class WikiPageTest extends MediaWikiLangTestCase {
                return $po;
        }
 
-       public function testGetParserOutput_nonexisting( ) {
+       public function testGetParserOutput_nonexisting() {
                static $count = 0;
-               $count ++;
+               $count++;
 
                $page = new WikiPage( new Title( "WikiPageTest_testGetParserOutput_nonexisting_$count" ) );
 
@@ -603,7 +602,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $this->assertFalse( $po, "getParserOutput() shall return false for non-existing pages." );
        }
 
-       public function testGetParserOutput_badrev( ) {
+       public function testGetParserOutput_badrev() {
                $page = $this->createPage( 'WikiPageTest_testGetParserOutput', "dummy", CONTENT_MODEL_WIKITEXT );
 
                $opt = new ParserOptions();
@@ -633,46 +632,46 @@ more stuff
                //NOTE: assume the Help namespace to contain wikitext
                return array(
                        array( 'Help:WikiPageTest_testReplaceSection',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       WikiPageTest::$sections,
-                                       "0",
-                                       "No more",
-                                       null,
-                                       trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
+                               CONTENT_MODEL_WIKITEXT,
+                               WikiPageTest::$sections,
+                               "0",
+                               "No more",
+                               null,
+                               trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
                        ),
                        array( 'Help:WikiPageTest_testReplaceSection',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       WikiPageTest::$sections,
-                                       "",
-                                       "No more",
-                                       null,
-                                       "No more"
+                               CONTENT_MODEL_WIKITEXT,
+                               WikiPageTest::$sections,
+                               "",
+                               "No more",
+                               null,
+                               "No more"
                        ),
                        array( 'Help:WikiPageTest_testReplaceSection',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       WikiPageTest::$sections,
-                                       "2",
-                                       "== TEST ==\nmore fun",
-                                       null,
-                                       trim( preg_replace( '/^== test ==.*== foo ==/sm',
-                                                                               "== TEST ==\nmore fun\n\n== foo ==",
-                                                                               WikiPageTest::$sections ) )
+                               CONTENT_MODEL_WIKITEXT,
+                               WikiPageTest::$sections,
+                               "2",
+                               "== TEST ==\nmore fun",
+                               null,
+                               trim( preg_replace( '/^== test ==.*== foo ==/sm',
+                                       "== TEST ==\nmore fun\n\n== foo ==",
+                                       WikiPageTest::$sections ) )
                        ),
                        array( 'Help:WikiPageTest_testReplaceSection',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       WikiPageTest::$sections,
-                                       "8",
-                                       "No more",
-                                       null,
-                                       trim( WikiPageTest::$sections )
+                               CONTENT_MODEL_WIKITEXT,
+                               WikiPageTest::$sections,
+                               "8",
+                               "No more",
+                               null,
+                               trim( WikiPageTest::$sections )
                        ),
                        array( 'Help:WikiPageTest_testReplaceSection',
-                                       CONTENT_MODEL_WIKITEXT,
-                                       WikiPageTest::$sections,
-                                       "new",
-                                       "No more",
-                                       "New",
-                                       trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
+                               CONTENT_MODEL_WIKITEXT,
+                               WikiPageTest::$sections,
+                               "new",
+                               "No more",
+                               "New",
+                               trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
                        ),
                );
        }
@@ -704,71 +703,71 @@ more stuff
 
        /* @todo FIXME: fix this!
        public function testGetUndoText() {
-               $this->checkHasDiff3();
+       $this->checkHasDiff3();
 
-               $text = "one";
-               $page = $this->createPage( "WikiPageTest_testGetUndoText", $text );
-               $rev1 = $page->getRevision();
+       $text = "one";
+       $page = $this->createPage( "WikiPageTest_testGetUndoText", $text );
+       $rev1 = $page->getRevision();
 
-               $text .= "\n\ntwo";
-               $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section two");
-               $rev2 = $page->getRevision();
+       $text .= "\n\ntwo";
+       $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");
-               $rev3 = $page->getRevision();
+       $text .= "\n\nthree";
+       $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");
-               $rev4 = $page->getRevision();
+       $text .= "\n\nfour";
+       $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");
-               $rev5 = $page->getRevision();
+       $text .= "\n\nfive";
+       $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");
-               $rev6 = $page->getRevision();
+       $text .= "\n\nsix";
+       $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section six");
+       $rev6 = $page->getRevision();
 
-               $undo6 = $page->getUndoText( $rev6 );
-               if ( $undo6 === false ) $this->fail( "getUndoText failed for rev6" );
-               $this->assertEquals( "one\n\ntwo\n\nthree\n\nfour\n\nfive", $undo6 );
+       $undo6 = $page->getUndoText( $rev6 );
+       if ( $undo6 === false ) $this->fail( "getUndoText failed for rev6" );
+       $this->assertEquals( "one\n\ntwo\n\nthree\n\nfour\n\nfive", $undo6 );
 
-               $undo3 = $page->getUndoText( $rev4, $rev2 );
-               if ( $undo3 === false ) $this->fail( "getUndoText failed for rev4..rev2" );
-               $this->assertEquals( "one\n\ntwo\n\nfive", $undo3 );
+       $undo3 = $page->getUndoText( $rev4, $rev2 );
+       if ( $undo3 === false ) $this->fail( "getUndoText failed for rev4..rev2" );
+       $this->assertEquals( "one\n\ntwo\n\nfive", $undo3 );
 
-               $undo2 = $page->getUndoText( $rev2 );
-               if ( $undo2 === false ) $this->fail( "getUndoText failed for rev2" );
-               $this->assertEquals( "one\n\nfive", $undo2 );
+       $undo2 = $page->getUndoText( $rev2 );
+       if ( $undo2 === false ) $this->fail( "getUndoText failed for rev2" );
+       $this->assertEquals( "one\n\nfive", $undo2 );
        }
-       */
+        */
 
        /**
         * @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();
-               $admin->setName("Admin");
+               $admin->setName( "Admin" );
 
                $text = "one";
                $page = $this->newPage( "WikiPageTest_testDoRollback" );
                $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
-                                                               "section one", EDIT_NEW, false, $admin );
+                       "section one", EDIT_NEW, false, $admin );
 
                $user1 = new User();
                $user1->setName( "127.0.1.11" );
                $text .= "\n\ntwo";
                $page = new WikiPage( $page->getTitle() );
                $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
-                                                               "adding section two", 0, false, $user1 );
+                       "adding section two", 0, false, $user1 );
 
                $user2 = new User();
                $user2->setName( "127.0.2.13" );
                $text .= "\n\nthree";
                $page = new WikiPage( $page->getTitle() );
                $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
-                                                               "adding section three", 0, false, $user2 );
+                       "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.
@@ -796,7 +795,7 @@ more stuff
 
                $page = new WikiPage( $page->getTitle() );
                $this->assertEquals( $rev2->getSha1(), $page->getRevision()->getSha1(),
-                                                               "rollback did not revert to the correct revision" );
+                       "rollback did not revert to the correct revision" );
                $this->assertEquals( "one\n\ntwo", $page->getContent()->getNativeData() );
        }
 
@@ -805,12 +804,12 @@ more stuff
         */
        public function testDoRollback() {
                $admin = new User();
-               $admin->setName("Admin");
+               $admin->setName( "Admin" );
 
                $text = "one";
                $page = $this->newPage( "WikiPageTest_testDoRollback" );
                $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
-                                                               "section one", EDIT_NEW, false, $admin );
+                       "section one", EDIT_NEW, false, $admin );
                $rev1 = $page->getRevision();
 
                $user1 = new User();
@@ -818,7 +817,7 @@ more stuff
                $text .= "\n\ntwo";
                $page = new WikiPage( $page->getTitle() );
                $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
-                                                               "adding section two", 0, false, $user1 );
+                       "adding section two", 0, false, $user1 );
 
                # now, try the rollback
                $admin->addGroup( "sysop" ); #XXX: make the test user a sysop...
@@ -831,11 +830,11 @@ more stuff
 
                $page = new WikiPage( $page->getTitle() );
                $this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(),
-                                                       "rollback did not revert to the correct revision" );
+                       "rollback did not revert to the correct revision" );
                $this->assertEquals( "one", $page->getContent()->getNativeData() );
        }
 
-       public static function provideGetAutosummary( ) {
+       public static function provideGetAutosummary() {
                return array(
                        array(
                                'Hello there, world!',
@@ -887,10 +886,10 @@ more stuff
                $summary = $page->getAutosummary( $old, $new, $flags );
 
                $this->assertTrue( (bool)preg_match( $expected, $summary ),
-                                                       "Autosummary didn't match expected pattern $expected: $summary" );
+                       "Autosummary didn't match expected pattern $expected: $summary" );
        }
 
-       public static function provideGetAutoDeleteReason( ) {
+       public static function provideGetAutoDeleteReason() {
                return array(
                        array(
                                array(),
@@ -927,10 +926,10 @@ 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 ),
+                                               . "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
@@ -962,8 +961,11 @@ more stuff
                foreach ( $edits as $edit ) {
                        $user = new User();
 
-                       if ( !empty( $edit[1] ) ) $user->setName( $edit[1] );
-                       else $user = $wgUser;
+                       if ( !empty( $edit[1] ) ) {
+                               $user->setName( $edit[1] );
+                       } else {
+                               $user = $wgUser;
+                       }
 
                        $content = ContentHandler::makeContent( $edit[0], $page->getTitle(), $page->getContentModel() );
 
@@ -974,12 +976,15 @@ more stuff
 
                $reason = $page->getAutoDeleteReason( $hasHistory );
 
-               if ( is_bool( $expectedResult ) || is_null( $expectedResult ) ) $this->assertEquals( $expectedResult, $reason );
-               else $this->assertTrue( (bool)preg_match( $expectedResult, $reason ),
-                                                               "Autosummary didn't match expected pattern $expectedResult: $reason" );
+               if ( is_bool( $expectedResult ) || is_null( $expectedResult ) ) {
+                       $this->assertEquals( $expectedResult, $reason );
+               } else {
+                       $this->assertTrue( (bool)preg_match( $expectedResult, $reason ),
+                               "Autosummary didn't match expected pattern $expectedResult: $reason" );
+               }
 
                $this->assertEquals( $expectedHistory, $hasHistory,
-                                                       "expected \$hasHistory to be " . var_export( $expectedHistory, true ) );
+                       "expected \$hasHistory to be " . var_export( $expectedHistory, true ) );
 
                $page->doDeleteArticle( "done" );
        }
@@ -987,10 +992,10 @@ more stuff
        public static function providePreSaveTransform() {
                return array(
                        array( 'hello this is ~~~',
-                                       "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
+                               "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
                        ),
                        array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
-                                       'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+                               'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
                        ),
                );
        }
@@ -1001,7 +1006,7 @@ more stuff
        public function testPreSaveTransform( $text, $expected ) {
                $this->hideDeprecated( 'WikiPage::preSaveTransform' );
                $user = new User();
-               $user->setName("127.0.0.1");
+               $user->setName( "127.0.0.1" );
 
                //NOTE: assume Help namespace to contain wikitext
                $page = $this->newPage( "Help:WikiPageTest_testPreloadTransform" );
index 7c9cbe3..d7227b4 100644 (file)
@@ -9,9 +9,10 @@ class XmlSelectTest extends MediaWikiTestCase {
                $this->setMwGlobals( array(
                        'wgHtml5' => true,
                        'wgWellFormedXml' => true,
-               ));
+               ) );
                $this->select = new XmlSelect();
        }
+
        protected function tearDown() {
                parent::tearDown();
                $this->select = null;
@@ -49,14 +50,14 @@ class XmlSelectTest extends MediaWikiTestCase {
                         * See http://en.wikipedia.org/wiki/Gray_code
                         */
                        #      $name   $id    $default
-                       array( false , false, false,  '<select></select>' ),
-                       array( false , false, 'foo',  '<select></select>' ),
-                       array( false , 'id' , 'foo',  '<select id="id"></select>' ),
-                       array( false , 'id' , false,  '<select id="id"></select>' ),
-                       array( 'name', 'id' , false,  '<select name="name" id="id"></select>' ),
-                       array( 'name', 'id' , 'foo',  '<select name="name" id="id"></select>' ),
-                       array( 'name', false, 'foo',  '<select name="name"></select>' ),
-                       array( 'name', false, false,  '<select name="name"></select>' ),
+                       array( false, false, false, '<select></select>' ),
+                       array( false, false, 'foo', '<select></select>' ),
+                       array( false, 'id', 'foo', '<select id="id"></select>' ),
+                       array( false, 'id', false, '<select id="id"></select>' ),
+                       array( 'name', 'id', false, '<select name="name" id="id"></select>' ),
+                       array( 'name', 'id', 'foo', '<select name="name" id="id"></select>' ),
+                       array( 'name', false, 'foo', '<select name="name"></select>' ),
+                       array( 'name', false, false, '<select name="name"></select>' ),
                );
        }
 
@@ -65,18 +66,22 @@ class XmlSelectTest extends MediaWikiTestCase {
                $this->select->addOption( 'foo' );
                $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
        }
+
        public function testAddOptionWithDefault() {
                $this->select->addOption( 'foo', true );
                $this->assertEquals( '<select><option value="1">foo</option></select>', $this->select->getHTML() );
        }
+
        public function testAddOptionWithFalse() {
                $this->select->addOption( 'foo', false );
                $this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
        }
+
        public function testAddOptionWithValueZero() {
                $this->select->addOption( 'foo', 0 );
                $this->assertEquals( '<select><option value="0">foo</option></select>', $this->select->getHTML() );
        }
+
        # End XmlSelect::addOption() similar to Xml::option
 
        public function testSetDefault() {
@@ -85,9 +90,9 @@ class XmlSelectTest extends MediaWikiTestCase {
                $this->select->addOption( 'bar1' );
                $this->select->addOption( 'foo2' );
                $this->assertEquals(
-'<select><option value="foo1">foo1</option>' . "\n" .
-'<option value="bar1" selected="">bar1</option>' . "\n" .
-'<option value="foo2">foo2</option></select>', $this->select->getHTML() );
+                       '<select><option value="foo1">foo1</option>' . "\n" .
+                               '<option value="bar1" selected="">bar1</option>' . "\n" .
+                               '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
        }
 
        /**
@@ -101,9 +106,9 @@ class XmlSelectTest extends MediaWikiTestCase {
                $this->select->addOption( 'foo2' );
                $this->select->setDefault( 'bar1' ); # setting default after adding options
                $this->assertEquals(
-'<select><option value="foo1">foo1</option>' . "\n" .
-'<option value="bar1" selected="">bar1</option>' . "\n" .
-'<option value="foo2">foo2</option></select>', $this->select->getHTML() );
+                       '<select><option value="foo1">foo1</option>' . "\n" .
+                               '<option value="bar1" selected="">bar1</option>' . "\n" .
+                               '<option value="foo2">foo2</option></select>', $this->select->getHTML() );
        }
 
        public function testGetAttributes() {
@@ -135,7 +140,7 @@ class XmlSelectTest extends MediaWikiTestCase {
                # verify string / integer
                $this->assertEquals(
                        $this->select->getAttribute( '1911' ),
-                       'razor' 
+                       'razor'
                );
                $this->assertEquals(
                        $this->select->getAttribute( 'dummy' ),
index b54731b..f482328 100644 (file)
@@ -11,20 +11,20 @@ class XmlTest extends MediaWikiTestCase {
                $langObj->setNamespaces( array(
                        -2 => 'Media',
                        -1 => 'Special',
-                       0  => '',
-                       1  => 'Talk',
-                       2  => 'User',
-                       3  => 'User_talk',
-                       4  => 'MyWiki',
-                       5  => 'MyWiki_Talk',
-                       6  => 'File',
-                       7  => 'File_talk',
-                       8  => 'MediaWiki',
-                       9  => 'MediaWiki_talk',
-                       10  => 'Template',
-                       11  => 'Template_talk',
-                       100  => 'Custom',
-                       101  => 'Custom_talk',
+                       0 => '',
+                       1 => 'Talk',
+                       2 => 'User',
+                       3 => 'User_talk',
+                       4 => 'MyWiki',
+                       5 => 'MyWiki_Talk',
+                       6 => 'File',
+                       7 => 'File_talk',
+                       8 => 'MediaWiki',
+                       9 => 'MediaWiki_talk',
+                       10 => 'Template',
+                       11 => 'Template_talk',
+                       100 => 'Custom',
+                       101 => 'Custom_talk',
                ) );
 
                $this->setMwGlobals( array(
@@ -35,7 +35,7 @@ class XmlTest extends MediaWikiTestCase {
        }
 
        public function testExpandAttributes() {
-               $this->assertNull( Xml::expandAttributes(null),
+               $this->assertNull( Xml::expandAttributes( null ),
                        'Converting a null list of attributes'
                );
                $this->assertEquals( '', Xml::expandAttributes( array() ),
@@ -44,8 +44,8 @@ class XmlTest extends MediaWikiTestCase {
        }
 
        public function testExpandAttributesException() {
-               $this->setExpectedException('MWException');
-               Xml::expandAttributes('string');
+               $this->setExpectedException( 'MWException' );
+               Xml::expandAttributes( 'string' );
        }
 
        function testElementOpen() {
@@ -71,6 +71,7 @@ class XmlTest extends MediaWikiTestCase {
                        'Input with a value of 0 (bug 23797)'
                );
        }
+
        function testElementEscaping() {
                $this->assertEquals(
                        '<element>hello &lt;there&gt; you &amp; you</element>',
@@ -105,53 +106,57 @@ class XmlTest extends MediaWikiTestCase {
                $this->assertEquals( '</element>', Xml::closeElement( 'element' ), 'closeElement() shortcut' );
        }
 
-       public function testDateMenu( ) {
-               $curYear   = intval(gmdate('Y'));
-               $prevYear  = $curYear - 1;
+       public function testDateMenu() {
+               $curYear = intval( gmdate( 'Y' ) );
+               $prevYear = $curYear - 1;
 
-               $curMonth  = intval(gmdate('n'));
+               $curMonth = intval( gmdate( 'n' ) );
                $prevMonth = $curMonth - 1;
-               if( $prevMonth == 0 ) { $prevMonth = 12; }
+               if ( $prevMonth == 0 ) {
+                       $prevMonth = 12;
+               }
                $nextMonth = $curMonth + 1;
-               if( $nextMonth == 13 ) { $nextMonth = 1; }
+               if ( $nextMonth == 13 ) {
+                       $nextMonth = 1;
+               }
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> <input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" .
-'<option value="1">January</option>' . "\n" .
-'<option value="2" selected="">February</option>' . "\n" .
-'<option value="3">March</option>' . "\n" .
-'<option value="4">April</option>' . "\n" .
-'<option value="5">May</option>' . "\n" .
-'<option value="6">June</option>' . "\n" .
-'<option value="7">July</option>' . "\n" .
-'<option value="8">August</option>' . "\n" .
-'<option value="9">September</option>' . "\n" .
-'<option value="10">October</option>' . "\n" .
-'<option value="11">November</option>' . "\n" .
-'<option value="12">December</option></select>',
+                               '<option value="1">January</option>' . "\n" .
+                               '<option value="2" selected="">February</option>' . "\n" .
+                               '<option value="3">March</option>' . "\n" .
+                               '<option value="4">April</option>' . "\n" .
+                               '<option value="5">May</option>' . "\n" .
+                               '<option value="6">June</option>' . "\n" .
+                               '<option value="7">July</option>' . "\n" .
+                               '<option value="8">August</option>' . "\n" .
+                               '<option value="9">September</option>' . "\n" .
+                               '<option value="10">October</option>' . "\n" .
+                               '<option value="11">November</option>' . "\n" .
+                               '<option value="12">December</option></select>',
                        Xml::dateMenu( 2011, 02 ),
                        "Date menu for february 2011"
                );
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> <input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" .
-'<option value="1">January</option>' . "\n" .
-'<option value="2">February</option>' . "\n" .
-'<option value="3">March</option>' . "\n" .
-'<option value="4">April</option>' . "\n" .
-'<option value="5">May</option>' . "\n" .
-'<option value="6">June</option>' . "\n" .
-'<option value="7">July</option>' . "\n" .
-'<option value="8">August</option>' . "\n" .
-'<option value="9">September</option>' . "\n" .
-'<option value="10">October</option>' . "\n" .
-'<option value="11">November</option>' . "\n" .
-'<option value="12">December</option></select>',
-                       Xml::dateMenu( 2011, -1),
+                               '<option value="1">January</option>' . "\n" .
+                               '<option value="2">February</option>' . "\n" .
+                               '<option value="3">March</option>' . "\n" .
+                               '<option value="4">April</option>' . "\n" .
+                               '<option value="5">May</option>' . "\n" .
+                               '<option value="6">June</option>' . "\n" .
+                               '<option value="7">July</option>' . "\n" .
+                               '<option value="8">August</option>' . "\n" .
+                               '<option value="9">September</option>' . "\n" .
+                               '<option value="10">October</option>' . "\n" .
+                               '<option value="11">November</option>' . "\n" .
+                               '<option value="12">December</option></select>',
+                       Xml::dateMenu( 2011, -1 ),
                        "Date menu with negative month for 'All'"
                );
                $this->assertEquals(
                        Xml::dateMenu( $curYear, $curMonth ),
-                       Xml::dateMenu( ''      , $curMonth ),
+                       Xml::dateMenu( '', $curMonth ),
                        "Date menu year is the current one when not specified"
                );
 
@@ -164,18 +169,18 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> <input id="year" maxlength="4" size="7" type="number" name="year" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" .
-'<option value="1">January</option>' . "\n" .
-'<option value="2">February</option>' . "\n" .
-'<option value="3">March</option>' . "\n" .
-'<option value="4">April</option>' . "\n" .
-'<option value="5">May</option>' . "\n" .
-'<option value="6">June</option>' . "\n" .
-'<option value="7">July</option>' . "\n" .
-'<option value="8">August</option>' . "\n" .
-'<option value="9">September</option>' . "\n" .
-'<option value="10">October</option>' . "\n" .
-'<option value="11">November</option>' . "\n" .
-'<option value="12">December</option></select>',
+                               '<option value="1">January</option>' . "\n" .
+                               '<option value="2">February</option>' . "\n" .
+                               '<option value="3">March</option>' . "\n" .
+                               '<option value="4">April</option>' . "\n" .
+                               '<option value="5">May</option>' . "\n" .
+                               '<option value="6">June</option>' . "\n" .
+                               '<option value="7">July</option>' . "\n" .
+                               '<option value="8">August</option>' . "\n" .
+                               '<option value="9">September</option>' . "\n" .
+                               '<option value="10">October</option>' . "\n" .
+                               '<option value="11">November</option>' . "\n" .
+                               '<option value="12">December</option></select>',
                        Xml::dateMenu( '', '' ),
                        "Date menu with neither year or month"
                );
@@ -210,6 +215,7 @@ class XmlTest extends MediaWikiTestCase {
                        'label() with no attribs'
                );
        }
+
        function testLabelAttributeCanOnlyBeClassOrTitle() {
                $this->assertEquals(
                        '<label for="id">name</label>',
@@ -229,10 +235,10 @@ class XmlTest extends MediaWikiTestCase {
                $this->assertEquals(
                        '<label for="id" class="nice" title="nice tooltip">name</label>',
                        Xml::label( 'name', 'id', array(
-                               'generated' => true,
-                               'class' => 'nice',
-                               'title' => 'nice tooltip',
-                               'anotherattr' => 'value',
+                                       'generated' => true,
+                                       'class' => 'nice',
+                                       'title' => 'nice tooltip',
+                                       'anotherattr' => 'value',
                                )
                        ),
                        'label() skip all attributes but "class" and "title"'
index 9a03d5c..3fea57a 100644 (file)
@@ -29,12 +29,12 @@ class ZipDirectoryReaderTest extends MediaWikiTestCase {
        }
 
        function testMultiDisk0() {
-               $this->readZipAssertError( 'split.zip', 'zip-unsupported', 
+               $this->readZipAssertError( 'split.zip', 'zip-unsupported',
                        'Split zip error' );
        }
 
        function testNoSignature() {
-               $this->readZipAssertError( 'nosig.zip', 'zip-wrong-format', 
+               $this->readZipAssertError( 'nosig.zip', 'zip-wrong-format',
                        'No signature should give "wrong format" error' );
        }
 
@@ -58,7 +58,7 @@ class ZipDirectoryReaderTest extends MediaWikiTestCase {
        }
 
        function testWrongCDStart() {
-               $this->readZipAssertError( 'wrong-cd-start-disk.zip', 'zip-unsupported', 
+               $this->readZipAssertError( 'wrong-cd-start-disk.zip', 'zip-unsupported',
                        'Wrong CD start disk error' );
        }
 
index 60f6537..f37e279 100644 (file)
@@ -142,7 +142,7 @@ class ApiCreateAccountTest extends ApiTestCase {
         */
        function testInvalidEmail() {
                global $wgEnableEmail;
-               if( !$wgEnableEmail ) {
+               if ( !$wgEnableEmail ) {
                        $this->markTestSkipped( 'email is not enabled, so createaccount does not check it' );
                }
                $this->doApiRequest( array(
index dd4d598..8f6b935 100644 (file)
@@ -45,7 +45,7 @@ class ApiBlockTest extends ApiTestCase {
                        $this->markTestIncomplete( "The user UTApiBlockee does not exist" );
                }
 
-               if( !isset( $data[0]['query']['pages'] ) ) {
+               if ( !isset( $data[0]['query']['pages'] ) ) {
                        $this->markTestIncomplete( "No block token found" );
                }
 
@@ -59,7 +59,7 @@ class ApiBlockTest extends ApiTestCase {
                        'reason' => 'Some reason',
                        'token' => $pageinfo['blocktoken'] ), null, false, self::$users['sysop']->user );
 
-               $block = Block::newFromTarget('UTApiBlockee');
+               $block = Block::newFromTarget( 'UTApiBlockee' );
 
                $this->assertTrue( !is_null( $block ), 'Block is valid' );
 
@@ -99,7 +99,7 @@ class ApiBlockTest extends ApiTestCase {
                                'action' => $action,
                                'user' => 'UTApiBlockee',
                                'reason' => 'Some reason',
-                               ),
+                       ),
                        null,
                        false,
                        self::$users['sysop']->user
@@ -111,7 +111,7 @@ class ApiBlockTest extends ApiTestCase {
         */
        function provideBlockUnblockAction() {
                return array(
-                       array( 'block'   ),
+                       array( 'block' ),
                        array( 'unblock' ),
                );
        }
index eaab300..da5eb33 100644 (file)
@@ -43,14 +43,15 @@ class ApiEditPageTest extends ApiTestCase {
                parent::teardown();
        }
 
-       function testEdit( ) {
+       function testEdit() {
                $name = 'Help:ApiEditPageTest_testEdit'; // assume Help namespace to default to wikitext
 
                // -- test new page --------------------------------------------
                $apiResult = $this->doApiRequestWithToken( array(
-                               'action' => 'edit',
-                               'title' => $name,
-                               'text' => 'some text', ) );
+                       'action' => 'edit',
+                       'title' => $name,
+                       'text' => 'some text',
+               ) );
                $apiResult = $apiResult[0];
 
                // Validate API result data
@@ -65,9 +66,10 @@ class ApiEditPageTest extends ApiTestCase {
 
                // -- test existing page, no change ----------------------------
                $data = $this->doApiRequestWithToken( array(
-                               'action' => 'edit',
-                               'title' => $name,
-                               'text' => 'some text', ) );
+                       'action' => 'edit',
+                       'title' => $name,
+                       'text' => 'some text',
+               ) );
 
                $this->assertEquals( 'Success', $data[0]['edit']['result'] );
 
@@ -76,9 +78,10 @@ class ApiEditPageTest extends ApiTestCase {
 
                // -- test existing page, with change --------------------------
                $data = $this->doApiRequestWithToken( array(
-                               'action' => 'edit',
-                               'title' => $name,
-                               'text' => 'different text' ) );
+                       'action' => 'edit',
+                       'title' => $name,
+                       'text' => 'different text'
+               ) );
 
                $this->assertEquals( 'Success', $data[0]['edit']['result'] );
 
@@ -94,7 +97,7 @@ class ApiEditPageTest extends ApiTestCase {
                );
        }
 
-       function testNonTextEdit( ) {
+       function testNonTextEdit() {
                $name = 'Dummy:ApiEditPageTest_testNonTextEdit';
                $data = serialize( 'some bla bla text' );
 
@@ -158,13 +161,13 @@ class ApiEditPageTest extends ApiTestCase {
                if ( $text !== null ) {
                        if ( $text === '' ) {
                                // can't create an empty page, so create it with some content
-                               list( $re,, ) = $this->doApiRequestWithToken( array(
+                               list( $re, , ) = $this->doApiRequestWithToken( array(
                                        'action' => 'edit',
                                        'title' => $name,
                                        'text' => '(dummy)', ) );
                        }
 
-                       list( $re,, ) = $this->doApiRequestWithToken( array(
+                       list( $re, , ) = $this->doApiRequestWithToken( array(
                                'action' => 'edit',
                                'title' => $name,
                                'text' => $text, ) );
@@ -173,7 +176,7 @@ class ApiEditPageTest extends ApiTestCase {
                }
 
                // -- try append/prepend --------------------------------------------
-               list( $re,, ) = $this->doApiRequestWithToken( array(
+               list( $re, , ) = $this->doApiRequestWithToken( array(
                        'action' => 'edit',
                        'title' => $name,
                        $op . 'text' => $append, ) );
@@ -221,12 +224,12 @@ class ApiEditPageTest extends ApiTestCase {
 
                // try to save edit, expect conflict
                try {
-                       list( $re,, ) = $this->doApiRequestWithToken( array(
+                       list( $re, , ) = $this->doApiRequestWithToken( array(
                                'action' => 'edit',
                                'title' => $name,
                                'text' => 'nix bar!',
                                'basetimestamp' => $baseTime,
-                               ), null, self::$users['sysop']->user );
+                       ), null, self::$users['sysop']->user );
 
                        $this->fail( 'edit conflict expected' );
                } catch ( UsageException $ex ) {
@@ -264,7 +267,7 @@ class ApiEditPageTest extends ApiTestCase {
                $this->forceRevisionDate( $rpage, '20120101020202' );
 
                // try to save edit; should work, because we follow the redirect
-               list( $re,, ) = $this->doApiRequestWithToken( array(
+               list( $re, , ) = $this->doApiRequestWithToken( array(
                        'action' => 'edit',
                        'title' => $rname,
                        'text' => 'nix bar!',
@@ -277,7 +280,7 @@ class ApiEditPageTest extends ApiTestCase {
 
                // try again, without following the redirect. Should fail.
                try {
-                       list( $re,, ) = $this->doApiRequestWithToken( array(
+                       list( $re, , ) = $this->doApiRequestWithToken( array(
                                'action' => 'edit',
                                'title' => $rname,
                                'text' => 'nix bar!',
@@ -326,7 +329,7 @@ class ApiEditPageTest extends ApiTestCase {
                $this->forceRevisionDate( $rpage, '20120101020202' );
 
                // try to save edit; should work, following the redirect.
-               list( $re,, ) = $this->doApiRequestWithToken( array(
+               list( $re, , ) = $this->doApiRequestWithToken( array(
                        'action' => 'edit',
                        'title' => $rname,
                        'text' => 'nix bar!',
index 445969b..4a23eea 100644 (file)
@@ -28,20 +28,20 @@ class ApiGeneratorTest extends MediaWikiTestCase {
        ) {
                $generators = $this->getApiQuery()->getGenerators();
                $this->assertArrayHasKey( $moduleName, $generators,
-                       "API module '$moduleName' of class '$moduleClass' (an ApiQueryGeneratorBase subclass) must be listed in ApiQuery::\$mQueryGenerators or added to \$wgAPIGeneratorModules."
+                       "API module '$moduleName' of class '$moduleClass' (an ApiQueryGeneratorBase subclass) must be listed in ApiQuery::\$mQueryGenerators or added to \$wgAPIGeneratorModules."
                );
        }
 
        /**
         * Returns API modules which are subclassing ApiQueryGeneratorBase.
         * Case format is:
-        *      (moduleName, moduleClass)
+        *     (moduleName, moduleClass)
         */
        public function provideApiquerygeneratorbaseChilds() {
                $cases = array();
                $modules = $this->getApiQuery()->getModuleManager()->getNamesWithClasses();
-               foreach( $modules as $moduleName => $moduleClass ) {
-                       if( !is_subclass_of( $moduleClass, 'ApiQueryGeneratorBase' ) ) {
+               foreach ( $modules as $moduleName => $moduleClass ) {
+                       if ( !is_subclass_of( $moduleClass, 'ApiQueryGeneratorBase' ) ) {
                                continue;
                        }
                        $cases[] = array( $moduleName, $moduleClass );
@@ -71,7 +71,7 @@ class ApiGeneratorTest extends MediaWikiTestCase {
        public function provideListedApiqueryGenerators() {
                $cases = array();
                $generators = $this->getApiQuery()->getGenerators();
-               foreach( $generators as $generatorName => $generatorClass ) {
+               foreach ( $generators as $generatorName => $generatorClass ) {
                        $cases[] = array( $generatorName, $generatorClass );
                }
                return $cases;
index 93ff24a..a42e5aa 100644 (file)
@@ -21,7 +21,7 @@ class ApiParseTest extends ApiTestCase {
                                'page' => $somePage ) );
 
                        $this->fail( "API did not return an error when parsing a nonexistent page" );
-               } catch(UsageException $ex){
+               } catch ( UsageException $ex ) {
                        $this->assertEquals( 'missingtitle', $ex->getCodeString(),
                                "Parse request for nonexistent page must give 'missingtitle' error: " . var_export( $ex->getMessageArray(), true ) );
                }
index 3ab77fd..a7f9229 100644 (file)
@@ -33,7 +33,7 @@ class ApiPurgeTest extends ApiTestCase {
                        "Purge request for three articles should give back three results received: " . var_export( $data[0]['purge'], true ) );
 
                $pages = array( 'UTPage' => 'purged', $somePage => 'missing', '%5D' => 'invalid' );
-               foreach( $data[0]['purge'] as $v ) {
+               foreach ( $data[0]['purge'] as $v ) {
                        $this->assertArrayHasKey( $pages[$v['title']], $v );
                }
        }
index 2f2f5f9..2277028 100644 (file)
@@ -12,7 +12,7 @@ class ApiTest extends ApiTestCase {
 
                $this->assertEquals(
                        null, $mock->requireOnlyOneParameter( array( "filename" => "foo.txt",
-                               "enablechunks" => false ), "filename", "enablechunks" ) );
+                       "enablechunks" => false ), "filename", "enablechunks" ) );
        }
 
        /**
@@ -23,7 +23,7 @@ class ApiTest extends ApiTestCase {
 
                $this->assertEquals(
                        null, $mock->requireOnlyOneParameter( array( "filename" => "foo.txt",
-                               "enablechunks" => 0 ), "filename", "enablechunks" ) );
+                       "enablechunks" => 0 ), "filename", "enablechunks" ) );
        }
 
        /**
@@ -34,7 +34,7 @@ class ApiTest extends ApiTestCase {
 
                $this->assertEquals(
                        null, $mock->requireOnlyOneParameter( array( "filename" => "foo.txt",
-                               "enablechunks" => true ), "filename", "enablechunks" ) );
+                       "enablechunks" => true ), "filename", "enablechunks" ) );
        }
 
        /**
@@ -92,12 +92,14 @@ class ApiTest extends ApiTestCase {
 
                $token = $result["login"]["token"];
 
-               $ret = $this->doApiRequest( array(
-                       "action" => "login",
-                       "lgtoken" => $token,
-                       "lgname" => $user->username,
-                       "lgpassword" => "badnowayinhell",
-                       ), $ret[2]
+               $ret = $this->doApiRequest(
+                       array(
+                               "action" => "login",
+                               "lgtoken" => $token,
+                               "lgname" => $user->username,
+                               "lgpassword" => "badnowayinhell",
+                       ),
+                       $ret[2]
                );
 
                $result = $ret[0];
@@ -119,9 +121,9 @@ class ApiTest extends ApiTestCase {
                $user->user->logOut();
 
                $ret = $this->doApiRequest( array(
-                       "action" => "login",
-                       "lgname" => $user->username,
-                       "lgpassword" => $user->password,
+                               "action" => "login",
+                               "lgname" => $user->username,
+                               "lgpassword" => $user->password,
                        )
                );
 
@@ -133,12 +135,14 @@ class ApiTest extends ApiTestCase {
                $this->assertEquals( "NeedToken", $a );
                $token = $result["login"]["token"];
 
-               $ret = $this->doApiRequest( array(
-                       "action" => "login",
-                       "lgtoken" => $token,
-                       "lgname" => $user->username,
-                       "lgpassword" => $user->password,
-                       ), $ret[2]
+               $ret = $this->doApiRequest(
+                       array(
+                               "action" => "login",
+                               "lgtoken" => $token,
+                               "lgname" => $user->username,
+                               "lgpassword" => $user->password,
+                       ),
+                       $ret[2]
                );
 
                $result = $ret[0];
@@ -153,7 +157,7 @@ class ApiTest extends ApiTestCase {
         * @group Broken
         */
        function testApiGotCookie() {
-               $this->markTestIncomplete( "The server can't do external HTTP requests, and the internal one won't give cookies"  );
+               $this->markTestIncomplete( "The server can't do external HTTP requests, and the internal one won't give cookies" );
 
                global $wgServer, $wgScriptPath;
 
@@ -165,8 +169,11 @@ class ApiTest extends ApiTestCase {
                $req = MWHttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
                        array( "method" => "POST",
                                "postData" => array(
-                               "lgname" => $user->username,
-                               "lgpassword" => $user->password ) ) );
+                                       "lgname" => $user->username,
+                                       "lgpassword" => $user->password
+                               )
+                       )
+               );
                $req->execute();
 
                libxml_use_internal_errors( true );
index 4e3f6e5..552fbfb 100644 (file)
@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 abstract class ApiTestCase extends MediaWikiLangTestCase {
        protected static $apiUrl;
@@ -145,12 +145,15 @@ abstract class ApiTestCase extends MediaWikiLangTestCase {
 
                $token = $data[0]['login']['token'];
 
-               $data = $this->doApiRequest( array(
-                       'action' => 'login',
-                       'lgtoken' => $token,
-                       'lgname' => self::$users['sysop']->username,
-                       'lgpassword' => self::$users['sysop']->password
-                       ), $data[2] );
+               $data = $this->doApiRequest(
+                       array(
+                               'action' => 'login',
+                               'lgtoken' => $token,
+                               'lgname' => self::$users['sysop']->username,
+                               'lgpassword' => self::$users['sysop']->password,
+                       ),
+                       $data[2]
+               );
 
                return $data;
        }
@@ -201,10 +204,11 @@ class UserWrapper {
 }
 
 class MockApi extends ApiBase {
-       public function execute() { }
-       public function getVersion() { }
+       public function execute() {}
+
+       public function getVersion() {}
 
-       public function __construct() { }
+       public function __construct() {}
 
        public function getAllowedParams() {
                return array(
index 458bea4..8028491 100644 (file)
@@ -47,7 +47,7 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                        // see if it now doesn't exist; reload
                        $title = Title::newFromText( $title->getText(), NS_FILE );
                }
-               return ! ( $title && $title instanceof Title && $title->exists() );
+               return !( $title && $title instanceof Title && $title->exists() );
        }
 
        /**
@@ -84,7 +84,7 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                $tmpName = tempnam( wfTempDir(), "" );
                if ( !file_exists( $filePath ) ) {
                        throw new Exception( "$filePath doesn't exist!" );
-               };
+               }
 
                if ( !copy( $filePath, $tmpName ) ) {
                        throw new Exception( "couldn't copy $filePath to $tmpName" );
@@ -96,19 +96,19 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                        throw new Exception( "couldn't stat $tmpName" );
                }
 
-               $_FILES[ $fieldName ] = array(
-                       'name'          => $fileName,
-                       'type'          => $type,
-                       'tmp_name'      => $tmpName,
-                       'size'          => $size,
-                       'error'         => null
+               $_FILES[$fieldName] = array(
+                       'name' => $fileName,
+                       'type' => $type,
+                       'tmp_name' => $tmpName,
+                       'size' => $size,
+                       'error' => null
                );
 
                return true;
 
        }
 
-       function fakeUploadChunk(  $fieldName, $fileName, $type, & $chunkData ) {
+       function fakeUploadChunk( $fieldName, $fileName, $type, & $chunkData ) {
                $tmpName = tempnam( wfTempDir(), "" );
                // copy the chunk data to temp location:
                if ( !file_put_contents( $tmpName, $chunkData ) ) {
@@ -121,19 +121,19 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                        throw new Exception( "couldn't stat $tmpName" );
                }
 
-               $_FILES[ $fieldName ] = array(
-                       'name'          => $fileName,
-                       'type'          => $type,
-                       'tmp_name'      => $tmpName,
-                       'size'          => $size,
-                       'error'         => null
+               $_FILES[$fieldName] = array(
+                       'name' => $fileName,
+                       'type' => $type,
+                       'tmp_name' => $tmpName,
+                       'size' => $size,
+                       'error' => null
                );
        }
 
        function clearTempUpload() {
-               if( isset( $_FILES['file']['tmp_name'] ) ) {
+               if ( isset( $_FILES['file']['tmp_name'] ) ) {
                        $tmp = $_FILES['file']['tmp_name'];
-                       if( file_exists( $tmp ) ) {
+                       if ( file_exists( $tmp ) ) {
                                unlink( $tmp );
                        }
                }
index 89c0c00..0d98b04 100644 (file)
@@ -107,8 +107,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                try {
                        $randomImageGenerator = new RandomImageGenerator();
                        $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() );
-               }
-               catch ( Exception $e ) {
+               } catch ( Exception $e ) {
                        $this->markTestIncomplete( $e->getMessage() );
                }
 
@@ -120,7 +119,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                $this->deleteFileByContent( $filePath );
 
 
-               if ($this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
@@ -129,7 +128,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filename' => $fileName,
                        'file' => 'dummy content',
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for $fileName",
+                       'text' => "This is the page text for $fileName",
                );
 
                $exception = false;
@@ -162,7 +161,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
 
                $this->deleteFileByFileName( $fileName );
 
-               if ($this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
@@ -171,7 +170,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filename' => $fileName,
                        'file' => 'dummy content',
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for $fileName",
+                       'text' => "This is the page text for $fileName",
                );
 
                $exception = false;
@@ -199,8 +198,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                try {
                        $randomImageGenerator = new RandomImageGenerator();
                        $filePaths = $randomImageGenerator->writeImages( 2, $extension, wfTempDir() );
-               }
-               catch ( Exception $e ) {
+               } catch ( Exception $e ) {
                        $this->markTestIncomplete( $e->getMessage() );
                }
 
@@ -216,12 +214,12 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filename' => $fileName,
                        'file' => 'dummy content',
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for $fileName",
+                       'text' => "This is the page text for $fileName",
                );
 
                // first upload .... should succeed
 
-               if ($this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[0] ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[0] ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
@@ -238,7 +236,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
 
                // second upload with the same name (but different content)
 
-               if ($this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[1] ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePaths[1] ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
@@ -272,8 +270,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                try {
                        $randomImageGenerator = new RandomImageGenerator();
                        $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() );
-               }
-               catch ( Exception $e ) {
+               } catch ( Exception $e ) {
                        $this->markTestIncomplete( $e->getMessage() );
                }
 
@@ -292,10 +289,10 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filename' => $fileNames[0],
                        'file' => 'dummy content',
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for " . $fileNames[0],
+                       'text' => "This is the page text for " . $fileNames[0],
                );
 
-               if ($this->fakeUploadFile( 'file', $fileNames[0], $mimeType, $filePaths[0] ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileNames[0], $mimeType, $filePaths[0] ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
@@ -313,7 +310,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
 
                // second upload with the same content (but different name)
 
-               if ($this->fakeUploadFile( 'file', $fileNames[1], $mimeType, $filePaths[0] ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileNames[1], $mimeType, $filePaths[0] ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
@@ -322,7 +319,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filename' => $fileNames[1],
                        'file' => 'dummy content',
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for " . $fileNames[1],
+                       'text' => "This is the page text for " . $fileNames[1],
                );
 
                $exception = false;
@@ -359,8 +356,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                try {
                        $randomImageGenerator = new RandomImageGenerator();
                        $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() );
-               }
-               catch ( Exception $e ) {
+               } catch ( Exception $e ) {
                        $this->markTestIncomplete( $e->getMessage() );
                }
 
@@ -371,17 +367,17 @@ class ApiUploadTest extends ApiTestCaseUpload {
                $this->deleteFileByFileName( $fileName );
                $this->deleteFileByContent( $filePath );
 
-               if ($this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
+               if ( !$this->fakeUploadFile( 'file', $fileName, $mimeType, $filePath ) ) {
                        $this->markTestIncomplete( "Couldn't upload file!\n" );
                }
 
                $params = array(
                        'action' => 'upload',
-                       'stash' => 1,
+                       'stash' => 1,
                        'filename' => $fileName,
                        'file' => 'dummy content',
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for $fileName",
+                       'text' => "This is the page text for $fileName",
                );
 
                $exception = false;
@@ -409,7 +405,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filekey' => $filekey,
                        'filename' => $fileName,
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for $fileName, altered",
+                       'text' => "This is the page text for $fileName, altered",
                );
 
                $this->clearFakeUploads();
@@ -428,8 +424,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                $this->deleteFileByFilename( $fileName );
                unlink( $filePath );
        }
-       
-       
+
        /**
         * @depends testLogin
         */
@@ -446,11 +441,10 @@ class ApiUploadTest extends ApiTestCaseUpload {
                $filePath = wfTempDir() . '/Oberaargletscher_from_Oberaar.jpg';
                try {
                        // Only download if the file is not avaliable in the temp location:
-                       if( !is_file( $filePath ) ){
-                               copy($url, $filePath); 
+                       if ( !is_file( $filePath ) ) {
+                               copy( $url, $filePath );
                        }
-               }
-               catch ( Exception $e ) {
+               } catch ( Exception $e ) {
                        $this->markTestIncomplete( $e->getMessage() );
                }
 
@@ -463,29 +457,29 @@ class ApiUploadTest extends ApiTestCaseUpload {
                // Base upload params: 
                $params = array(
                        'action' => 'upload',
-                       'stash' => 1,
+                       'stash' => 1,
                        'filename' => $fileName,
                        'filesize' => $fileSize,
                        'offset' => 0,
                );
-               
+
                // Upload chunks
                $chunkSessionKey = false;
                $resultOffset = 0;
                // Open the file: 
-               $handle = @fopen ($filePath, "r");
-               if( $handle === false ){
+               $handle = @fopen( $filePath, "r" );
+               if ( $handle === false ) {
                        $this->markTestIncomplete( "could not open file: $filePath" );
                }
-               while (!feof ($handle)) {
+               while ( !feof( $handle ) ) {
                        // Get the current chunk
                        $chunkData = @fread( $handle, $chunkSize );
 
                        // Upload the current chunk into the $_FILE object:
                        $this->fakeUploadChunk( 'chunk', 'blob', $mimeType, $chunkData );
-                       
+
                        // Check for chunkSessionKey
-                       if( !$chunkSessionKey ){
+                       if ( !$chunkSessionKey ) {
                                // Upload fist chunk ( and get the session key )
                                try {
                                        list( $result, $request, $session ) = $this->doApiRequestWithToken( $params, $session,
@@ -497,7 +491,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                                $this->assertTrue( isset( $result['upload'] ) );
                                $this->assertTrue( isset( $result['upload']['filekey'] ) );
                                // If we don't get a session key mark test incomplete. 
-                               if( ! isset( $result['upload']['filekey'] ) ){
+                               if ( !isset( $result['upload']['filekey'] ) ) {
                                        $this->markTestIncomplete( "no filekey provided" );
                                }
                                $chunkSessionKey = $result['upload']['filekey'];
@@ -523,9 +517,9 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        // Make sure we got a valid chunk continue: 
                        $this->assertTrue( isset( $result['upload'] ) );
                        $this->assertTrue( isset( $result['upload']['filekey'] ) );
-                       
+
                        // Check if we were on the last chunk: 
-                       if( $params['offset'] + $chunkSize >=  $fileSize ){
+                       if ( $params['offset'] + $chunkSize >= $fileSize ) {
                                $this->assertEquals( 'Success', $result['upload']['result'] );
                                break;
                        } else {
@@ -533,11 +527,11 @@ class ApiUploadTest extends ApiTestCaseUpload {
                                // update $resultOffset
                                $resultOffset = $result['upload']['offset'];
                        }
-               } 
-               fclose ($handle); 
-        
+               }
+               fclose( $handle );
+
                // Check that we got a valid file result:
-               wfDebug( __METHOD__ . " hohoh filesize {$fileSize} info {$result['upload']['imageinfo']['size']}\n\n");
+               wfDebug( __METHOD__ . " hohoh filesize {$fileSize} info {$result['upload']['imageinfo']['size']}\n\n" );
                $this->assertEquals( $fileSize, $result['upload']['imageinfo']['size'] );
                $this->assertEquals( $mimeType, $result['upload']['imageinfo']['mime'] );
                $this->assertTrue( isset( $result['upload']['filekey'] ) );
@@ -549,7 +543,7 @@ class ApiUploadTest extends ApiTestCaseUpload {
                        'filekey' => $filekey,
                        'filename' => $fileName,
                        'comment' => 'dummy comment',
-                       'text'  => "This is the page text for $fileName, altered",
+                       'text' => "This is the page text for $fileName, altered",
                );
                $this->clearFakeUploads();
                $exception = false;