Merge "Revert "Adding sanity check to Title::isRedirect().""
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageTest.php
index e355a38..a1a6d59 100644 (file)
@@ -537,48 +537,48 @@ class LanguageTest extends MediaWikiTestCase {
                return array(
                        array(
                                0,
-                               '0 B',
-                               'Zero bytes'
+                               "0 B",
+                               "Zero bytes"
                        ),
                        array(
                                1024,
-                               '1 KB',
-                               '1 kilobyte'
+                               "1 KB",
+                               "1 kilobyte"
                        ),
                        array(
                                1024 * 1024,
-                               '1 MB',
-                               '1,024 megabytes'
+                               "1 MB",
+                               "1,024 megabytes"
                        ),
                        array(
                                1024 * 1024 * 1024,
-                               '1 GB',
-                               '1 gigabytes'
+                               "1 GB",
+                               "1 gigabytes"
                        ),
                        array(
                                pow( 1024, 4 ),
-                               '1 TB',
-                               '1 terabyte'
+                               "1 TB",
+                               "1 terabyte"
                        ),
                        array(
                                pow( 1024, 5 ),
-                               '1 PB',
-                               '1 petabyte'
+                               "1 PB",
+                               "1 petabyte"
                        ),
                        array(
                                pow( 1024, 6 ),
-                               '1 EB',
-                               '1,024 exabyte'
+                               "1 EB",
+                               "1,024 exabyte"
                        ),
                        array(
                                pow( 1024, 7 ),
-                               '1 ZB',
-                               '1 zetabyte'
+                               "1 ZB",
+                               "1 zetabyte"
                        ),
                        array(
                                pow( 1024, 8 ),
-                               '1 YB',
-                               '1 yottabyte'
+                               "1 YB",
+                               "1 yottabyte"
                        ),
                        // How big!? THIS BIG!
                );
@@ -599,69 +599,71 @@ class LanguageTest extends MediaWikiTestCase {
                return array(
                        array(
                                0,
-                               '0bps',
-                               '0 bits per second'
+                               "0bps",
+                               "0 bits per second"
                        ),
                        array(
                                999,
-                               '999bps',
-                               '999 bits per second'
+                               "999bps",
+                               "999 bits per second"
                        ),
                        array(
                                1000,
-                               '1kbps',
-                               '1 kilobit per second'
+                               "1kbps",
+                               "1 kilobit per second"
                        ),
                        array(
                                1000 * 1000,
-                               '1Mbps',
-                               '1 megabit per second'
+                               "1Mbps",
+                               "1 megabit per second"
                        ),
                        array(
                                pow( 10, 9 ),
-                               '1Gbps',
-                               '1 gigabit per second'
+                               "1Gbps",
+                               "1 gigabit per second"
                        ),
                        array(
                                pow( 10, 12 ),
-                               '1Tbps',
-                               '1 terabit per second'
+                               "1Tbps",
+                               "1 terabit per second"
                        ),
                        array(
                                pow( 10, 15 ),
-                               '1Pbps',
-                               '1 petabit per second'
+                               "1Pbps",
+                               "1 petabit per second"
                        ),
                        array(
                                pow( 10, 18 ),
-                               '1Ebps',
-                               '1 exabit per second'
+                               "1Ebps",
+                               "1 exabit per second"
                        ),
                        array(
                                pow( 10, 21 ),
-                               '1Zbps',
-                               '1 zetabit per second'
+                               "1Zbps",
+                               "1 zetabit per second"
                        ),
                        array(
                                pow( 10, 24 ),
-                               '1Ybps',
-                               '1 yottabit per second'
+                               "1Ybps",
+                               "1 yottabit per second"
                        ),
                        array(
                                pow( 10, 27 ),
-                               '1,000Ybps',
-                               '1,000 yottabits per second'
+                               "1,000Ybps",
+                               "1,000 yottabits per second"
                        ),
                );
        }
 
+
+
        /**
         * @dataProvider provideFormatDuration
         */
-       function testFormatDuration( $duration, $expected ) {
+       function testFormatDuration( $duration, $expected, $intervals = array() ) {
                $this->assertEquals(
                        $expected,
-                       $this->lang->formatDuration( $duration ),
+                       $this->lang->formatDuration( $duration, $intervals ),
                        "formatDuration('$duration'): $expected"
                );
        }
@@ -752,6 +754,105 @@ class LanguageTest extends MediaWikiTestCase {
                                42 * 1000 * 31557600 + 42,
                                '42 millennia and 42 seconds'
                        ),
+                       array(
+                               60,
+                               '60 seconds',
+                               array( 'seconds' ),
+                       ),
+                       array(
+                               61,
+                               '61 seconds',
+                               array( 'seconds' ),
+                       ),
+                       array(
+                               1,
+                               '1 second',
+                               array( 'seconds' ),
+                       ),
+                       array(
+                               31557600 + 2 * 86400 + 9000,
+                               '1 year, 2 days and 150 minutes',
+                               array( 'years', 'days', 'minutes' ),
+                       ),
+                       array(
+                               42,
+                               '0 days',
+                               array( 'years', 'days' ),
+                       ),
+                       array(
+                               31557600 + 2 * 86400 + 9000,
+                               '1 year, 2 days and 150 minutes',
+                               array( 'minutes', 'days', 'years' ),
+                       ),
+                       array(
+                               42,
+                               '0 days',
+                               array( 'days', 'years' ),
+                       ),
+               );
+       }
+
+       /**\r
+        * @dataProvider provideCheckTitleEncodingData\r
+        */\r
+       function testCheckTitleEncoding( $s ) {\r
+               $this->assertEquals(\r
+                       $s,\r
+                       $this->lang->checkTitleEncoding($s),\r
+                       "checkTitleEncoding('$s')"\r
+               );\r
+       }\r
+
+       function provideCheckTitleEncodingData() {
+               return array (
+                       array( "" ),
+                       array( "United States of America" ), // 7bit ASCII
+                       array( rawurldecode( "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e" ) ),
+                       array(
+                               rawurldecode(
+                                       "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn"
+                               )
+                       ),
+                       // The following two data sets come from bug 36839. They fail if checkTitleEncoding uses a regexp to test for
+                       // valid UTF-8 encoding and the pcre.recursion_limit is low (like, say, 1024). They succeed if checkTitleEncoding
+                   // uses mb_check_encoding for its test.
+                       array(
+                               rawurldecode(
+                                       "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn%7C"
+                                       . "Catherine%20Willows%7CDavid%20Hodges%7CDavid%20Phillips%7CGil%20Grissom%7CGreg%20Sanders%7CHodges%7C"
+                                       . "Internet%20Movie%20Database%7CJim%20Brass%7CLady%20Heather%7C"
+                                       . "Les%20Experts%20(s%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e)%7CLes%20Experts%20:%20Manhattan%7C"
+                                       . "Les%20Experts%20:%20Miami%7CListe%20des%20personnages%20des%20Experts%7C"
+                                       . "Liste%20des%20%C3%A9pisodes%20des%20Experts%7CMod%C3%A8le%20discussion:Palette%20Les%20Experts%7C"
+                                       . "Nick%20Stokes%7CPersonnage%20de%20fiction%7CPersonnage%20fictif%7CPersonnage%20de%20fiction%7C"
+                                       . "Personnages%20r%C3%A9currents%20dans%20Les%20Experts%7CRaymond%20Langston%7CRiley%20Adams%7C"
+                                       . "Saison%201%20des%20Experts%7CSaison%2010%20des%20Experts%7CSaison%2011%20des%20Experts%7C"
+                                       . "Saison%2012%20des%20Experts%7CSaison%202%20des%20Experts%7CSaison%203%20des%20Experts%7C"
+                                       . "Saison%204%20des%20Experts%7CSaison%205%20des%20Experts%7CSaison%206%20des%20Experts%7C"
+                                       . "Saison%207%20des%20Experts%7CSaison%208%20des%20Experts%7CSaison%209%20des%20Experts%7C"
+                                       . "Sara%20Sidle%7CSofia%20Curtis%7CS%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e%7CWallace%20Langham%7C"
+                                       . "Warrick%20Brown%7CWendy%20Simms%7C%C3%89tats-Unis"
+                               ),
+                       ),
+                       array(
+                               rawurldecode(
+                                       "Mod%C3%A8le%3AArrondissements%20homonymes%7CMod%C3%A8le%3ABandeau%20standard%20pour%20page%20d'homonymie%7C"
+                                       . "Mod%C3%A8le%3ABatailles%20homonymes%7CMod%C3%A8le%3ACantons%20homonymes%7C"
+                                       . "Mod%C3%A8le%3ACommunes%20fran%C3%A7aises%20homonymes%7CMod%C3%A8le%3AFilms%20homonymes%7C"
+                                       . "Mod%C3%A8le%3AGouvernements%20homonymes%7CMod%C3%A8le%3AGuerres%20homonymes%7CMod%C3%A8le%3AHomonymie%7C"
+                                       . "Mod%C3%A8le%3AHomonymie%20bateau%7CMod%C3%A8le%3AHomonymie%20d'%C3%A9tablissements%20scolaires%20ou"
+                                       . "%20universitaires%7CMod%C3%A8le%3AHomonymie%20d'%C3%AEles%7CMod%C3%A8le%3AHomonymie%20de%20clubs%20sportifs%7C"
+                                       . "Mod%C3%A8le%3AHomonymie%20de%20comt%C3%A9s%7CMod%C3%A8le%3AHomonymie%20de%20monument%7C"
+                                       . "Mod%C3%A8le%3AHomonymie%20de%20nom%20romain%7CMod%C3%A8le%3AHomonymie%20de%20parti%20politique%7C"
+                                       . "Mod%C3%A8le%3AHomonymie%20de%20route%7CMod%C3%A8le%3AHomonymie%20dynastique%7C"
+                                       . "Mod%C3%A8le%3AHomonymie%20vid%C3%A9oludique%7CMod%C3%A8le%3AHomonymie%20%C3%A9difice%20religieux%7C"
+                                       . "Mod%C3%A8le%3AInternationalisation%7CMod%C3%A8le%3AIsom%C3%A9rie%7CMod%C3%A8le%3AParonymie%7C"
+                                       . "Mod%C3%A8le%3APatronyme%7CMod%C3%A8le%3APatronyme%20basque%7CMod%C3%A8le%3APatronyme%20italien%7C"
+                                       . "Mod%C3%A8le%3APatronymie%7CMod%C3%A8le%3APersonnes%20homonymes%7CMod%C3%A8le%3ASaints%20homonymes%7C"
+                                       . "Mod%C3%A8le%3ATitres%20homonymes%7CMod%C3%A8le%3AToponymie%7CMod%C3%A8le%3AUnit%C3%A9s%20homonymes%7C"
+                                       . "Mod%C3%A8le%3AVilles%20homonymes%7CMod%C3%A8le%3A%C3%89difices%20religieux%20homonymes"
+                               )
+                       )
                );
        }
 }