Merge "API: Warn when unsupported PHP array syntax is used"
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / GlobalTest.php
index f67f696..06b512d 100644 (file)
@@ -80,7 +80,11 @@ class GlobalTest extends MediaWikiTestCase {
        public function testExpandIRI() {
                $this->assertEquals(
                        "https://te.wikibooks.org/wiki/ఉబుంటు_వాడుకరి_మార్గదర్శని",
-                       wfExpandIRI( "https://te.wikibooks.org/wiki/%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) );
+                       wfExpandIRI( "https://te.wikibooks.org/wiki/"
+                               . "%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_"
+                               . "%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_"
+                               . "%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0"
+                               . "%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) );
        }
 
        /**
@@ -125,11 +129,20 @@ class GlobalTest extends MediaWikiTestCase {
                        array( array( 'foo' => false ), '' ), // false test
                        array( array( 'foo' => null ), '' ), // null test
                        array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
-                       array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
+                       array(
+                               array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ),
+                               'foo=bar&baz=is&asdf=qwerty'
+                       ), // multi-item test
                        array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
-                       array( array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ), 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' ),
+                       array(
+                               array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ),
+                               'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf'
+                       ),
                        array( array( 'foo' => array( 'bar', 'baz' ) ), 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
-                       array( array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ), 'foo%5Bbar%5D%5Bbar%5D=baz' ),
+                       array(
+                               array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ),
+                               'foo%5Bbar%5D%5Bbar%5D=baz'
+                       ),
                );
        }
 
@@ -161,9 +174,15 @@ class GlobalTest extends MediaWikiTestCase {
                        array( 'foo=bar&qwerty=asdf', array( 'foo' => 'bar', 'qwerty' => 'asdf' ) ), // multiple value
                        array( 'foo=A%26B%3D5%2B6%40%21%22%27', array( 'foo' => 'A&B=5+6@!"\'' ) ), // urldecoding test
                        array( 'foo%5Bbar%5D=baz', array( 'foo' => array( 'bar' => 'baz' ) ) ),
-                       array( 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf', array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ) ),
+                       array(
+                               'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf',
+                               array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) )
+                       ),
                        array( 'foo%5B0%5D=bar&foo%5B1%5D=baz', array( 'foo' => array( 0 => 'bar', 1 => 'baz' ) ) ),
-                       array( 'foo%5Bbar%5D%5Bbar%5D=baz', array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ) ),
+                       array(
+                               'foo%5Bbar%5D%5Bbar%5D=baz',
+                               array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) )
+                       ),
                );
        }
 
@@ -288,15 +307,24 @@ class GlobalTest extends MediaWikiTestCase {
                unlink( $wgDebugLogFile );
 
                wfDebug( "\00305This has böth UTF and control chars\003" );
-               $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
+               $this->assertEquals(
+                       " 05This has böth UTF and control chars ",
+                       file_get_contents( $wgDebugLogFile )
+               );
                unlink( $wgDebugLogFile );
 
                wfDebugMem();
-               $this->assertGreaterThan( 1000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
+               $this->assertGreaterThan(
+                       1000,
+                       preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) )
+               );
                unlink( $wgDebugLogFile );
 
                wfDebugMem( true );
-               $this->assertGreaterThan( 1000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
+               $this->assertGreaterThan(
+                       1000000,
+                       preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) )
+               );
                unlink( $wgDebugLogFile );
 
                $wgDebugLogFile = $old_log_file;
@@ -437,11 +465,11 @@ class GlobalTest extends MediaWikiTestCase {
        }
 
        /**
-        * @param String $old: Text as it was in the database
-        * @param String $mine: Text submitted while user was editing
-        * @param String $yours: Text submitted by the user
-        * @param Boolean $expectedMergeResult Whether the merge should be a success
-        * @param String $expectedText: Text after merge has been completed
+        * @param string $old Text as it was in the database
+        * @param string $mine Text submitted while user was editing
+        * @param string $yours Text submitted by the user
+        * @param bool $expectedMergeResult Whether the merge should be a success
+        * @param string $expectedText Text after merge has been completed
         *
         * @dataProvider provideMerge()
         * @group medium
@@ -591,13 +619,48 @@ class GlobalTest extends MediaWikiTestCase {
                $protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' );
                foreach ( $protocols as $pDesc => $p ) {
                        $a = array_merge( $a, array(
-                               array( "$p//www.example.com", array(), false, "No matches for empty domains array, $pDesc URL" ),
-                               array( "$p//www.example.com", array( 'www.example.com' ), true, "Exact match in domains array, $pDesc URL" ),
-                               array( "$p//www.example.com", array( 'example.com' ), true, "Match without subdomain in domains array, $pDesc URL" ),
-                               array( "$p//www.example2.com", array( 'www.example.com', 'www.example2.com', 'www.example3.com' ), true, "Exact match with other domains in array, $pDesc URL" ),
-                               array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ),
-                               array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ),
-                               array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), false, "Non-matching substring of domain, $pDesc URL" ),
+                               array(
+                                       "$p//www.example.com",
+                                       array(),
+                                       false,
+                                       "No matches for empty domains array, $pDesc URL"
+                               ),
+                               array(
+                                       "$p//www.example.com",
+                                       array( 'www.example.com' ),
+                                       true,
+                                       "Exact match in domains array, $pDesc URL"
+                               ),
+                               array(
+                                       "$p//www.example.com",
+                                       array( 'example.com' ),
+                                       true,
+                                       "Match without subdomain in domains array, $pDesc URL"
+                               ),
+                               array(
+                                       "$p//www.example2.com",
+                                       array( 'www.example.com', 'www.example2.com', 'www.example3.com' ),
+                                       true,
+                                       "Exact match with other domains in array, $pDesc URL"
+                               ),
+                               array(
+                                       "$p//www.example2.com",
+                                       array( 'example.com', 'example2.com', 'example3,com' ),
+                                       true,
+                                       "Match without subdomain with other domains in array, $pDesc URL"
+                               ),
+                               array(
+                                       "$p//www.example4.com",
+                                       array( 'example.com', 'example2.com', 'example3,com' ),
+                                       false,
+                                       "Domain not in array, $pDesc URL"
+                               ),
+                               array(
+                                       "$p//nds-nl.wikipedia.org",
+                                       array( 'nl.wikipedia.org' ),
+                                       false,
+                                       "Non-matching substring of domain, $pDesc URL"
+                               ),
                        ) );
                }
 
@@ -620,7 +683,9 @@ class GlobalTest extends MediaWikiTestCase {
         * @dataProvider provideWfShellMaintenanceCmdList
         * @covers ::wfShellMaintenanceCmd
         */
-       public function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) {
+       public function testWfShellMaintenanceCmd( $script, $parameters, $options,
+               $expected, $description
+       ) {
                if ( wfIsWindows() ) {
                        // Approximation that's good enough for our purposes just now
                        $expected = str_replace( "'", '"', $expected );
@@ -642,9 +707,13 @@ class GlobalTest extends MediaWikiTestCase {
                        array( 'eval.php', array( '--help', '--test', 'X' ), array( 'wrapper' => 'MWScript.php' ),
                                "'$wgPhpCli' 'MWScript.php' 'eval.php' '--help' '--test' 'X'",
                                "Called eval.php --help --test with wrapper option" ),
-                       array( 'eval.php', array( '--help', '--test', 'y' ), array( 'php' => 'php5', 'wrapper' => 'MWScript.php' ),
+                       array(
+                               'eval.php',
+                               array( '--help', '--test', 'y' ),
+                               array( 'php' => 'php5', 'wrapper' => 'MWScript.php' ),
                                "'php5' 'MWScript.php' 'eval.php' '--help' '--test' 'y'",
-                               "Called eval.php --help --test with wrapper and php option" ),
+                               "Called eval.php --help --test with wrapper and php option"
+                       ),
                );
        }
        /* @TODO many more! */