Merge "RequestContext: Load the request object for getRequest on first call"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / FormatMetadataTest.php
index 002e2cb..22383e1 100644 (file)
@@ -37,35 +37,62 @@ class FormatMetadataTest extends MediaWikiMediaTestCase {
        }
 
        /**
-        * @param string $filename
-        * @param int $expected Total image area
-        * @dataProvider provideFlattenArray
-        * @covers FormatMetadata::flattenArray
+        * @param mixed $input
+        * @param mixed $output
+        * @dataProvider provideResolveMultivalueValue
+        * @covers FormatMetadata::resolveMultivalueValue
         */
-       public function testFlattenArray( $vals, $type, $noHtml, $ctx, $expected ) {
-               $actual = FormatMetadata::flattenArray( $vals, $type, $noHtml, $ctx );
-               $this->assertEquals( $expected, $actual );
+       public function testResolveMultivalueValue( $input, $output ) {
+               $formatMetadata = new FormatMetadata();
+               $class = new ReflectionClass( 'FormatMetadata' );
+               $method = $class->getMethod( 'resolveMultivalueValue' );
+               $method->setAccessible( true );
+               $actualInput = $method->invoke( $formatMetadata, $input );
+               $this->assertEquals( $output, $actualInput );
        }
 
-       public static function provideFlattenArray() {
+       public function provideResolveMultivalueValue() {
                return array(
-                       array(
-                               array( 1, 2, 3 ), 'ul', false, false,
-                               "<ul><li>1</li>\n<li>2</li>\n<li>3</li></ul>",
+                       'nonArray' => array(
+                               'foo',
+                               'foo'
                        ),
-                       array(
-                               array( 1, 2, 3 ), 'ol', false, false,
-                               "<ol><li>1</li>\n<li>2</li>\n<li>3</li></ol>",
+                       'multiValue' => array(
+                               array( 'first', 'second', 'third', '_type' => 'ol' ),
+                               'first'
                        ),
-                       array(
-                               array( 1, 2, 3 ), 'ul', true, false,
-                               "\n*1\n*2\n*3",
+                       'noType' => array(
+                               array( 'first', 'second', 'third' ),
+                               'first'
                        ),
-                       array(
-                               array( 1, 2, 3 ), 'ol', true, false,
-                               "\n#1\n#2\n#3",
+                       'typeFirst' => array(
+                               array( '_type' => 'ol', 'first', 'second', 'third' ),
+                               'first'
+                       ),
+                       'multilang' => array(
+                               array(
+                                       'en' => 'first',
+                                       'de' => 'Erste',
+                                       '_type' => 'lang'
+                               ),
+                               array(
+                                       'en' => 'first',
+                                       'de' => 'Erste',
+                                       '_type' => 'lang'
+                               ),
+                       ),
+                       'multilang-multivalue' => array(
+                               array(
+                                       'en' => array( 'first', 'second' ),
+                                       'de' => array( 'Erste', 'Zweite' ),
+                                       '_type' => 'lang'
+                               ),
+                               array(
+                                       'en' => 'first',
+                                       'de' => 'Erste',
+                                       '_type' => 'lang'
+                               ),
                        ),
-                       // TODO: more test cases
                );
        }
 }