Add tests for 47e0f0c3 (MessageCache::normalizeKey())
[lhc/web/wiklou.git] / tests / phpunit / includes / cache / MessageCacheTest.php
index 442e9f9..5302b36 100644 (file)
@@ -52,7 +52,7 @@ class MessageCacheTest extends MediaWikiLangTestCase {
                $this->makePage( 'MessageCacheTest-FullKeyTest', 'ru' );
 
                // In content language -- get base if no derivative
-               $this->makePage( 'FallbackLanguageTest-NoDervContLang', 'de', 'de/none', false );
+               $this->makePage( 'FallbackLanguageTest-NoDervContLang', 'de', 'de/none' );
        }
 
        /**
@@ -61,15 +61,14 @@ class MessageCacheTest extends MediaWikiLangTestCase {
         * @param string $title Title of page to be created
         * @param string $lang Language and content of the created page
         * @param string|null $content Content of the created page, or null for a generic string
-        * @param bool $createSubPage Set to false if a root page should be created
         */
-       protected function makePage( $title, $lang, $content = null, $createSubPage = true ) {
+       protected function makePage( $title, $lang, $content = null ) {
                global $wgContLang;
 
                if ( $content === null ) {
                        $content = $lang;
                }
-               if ( $lang !== $wgContLang->getCode() || $createSubPage ) {
+               if ( $lang !== $wgContLang->getCode() ) {
                        $title = "$title/$lang";
                }
 
@@ -125,4 +124,26 @@ class MessageCacheTest extends MediaWikiLangTestCase {
                );
        }
 
+       /**
+        * @dataProvider provideNormalizeKey
+        */
+       public function testNormalizeKey( $key, $expected ) {
+               $actual = MessageCache::normalizeKey( $key );
+               $this->assertEquals( $expected, $actual );
+       }
+
+       public function provideNormalizeKey() {
+               return array(
+                       array( 'Foo', 'foo' ),
+                       array( 'foo', 'foo' ),
+                       array( 'fOo', 'fOo' ),
+                       array( 'FOO', 'fOO' ),
+                       array( 'Foo bar', 'foo_bar' ),
+                       array( 'Ćab', 'ćab' ),
+                       array( 'Ćab_e 3', 'ćab_e_3' ),
+                       array( 'ĆAB', 'ćAB' ),
+                       array( 'ćab', 'ćab' ),
+                       array( 'ćaB', 'ćaB' ),
+               );
+       }
 }