Merge "Add and use Title::getOtherPage()"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / FormatMetadataTest.php
index daaefc0..54758f9 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group Media
+ */
 class FormatMetadataTest extends MediaWikiMediaTestCase {
 
        protected function setUp() {
@@ -65,4 +68,36 @@ class FormatMetadataTest extends MediaWikiMediaTestCase {
                        // TODO: more test cases
                );
        }
+
+       /**
+        * @param mixed $input
+        * @param mixed $output
+        * @dataProvider provideResolveMultivalueValue
+        * @covers FormatMetadata::resolveMultivalueValue
+        */
+       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 function provideResolveMultivalueValue() {
+               return array(
+                       'nonArray' => array( 'foo', 'foo' ),
+                       'multiValue' => array( array( 'first', 'second', 'third', '_type' => 'ol' ), 'first' ),
+                       'noType' => array( array( 'first', 'second', 'third' ), 'first' ),
+                       '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' ),
+                       ),
+               );
+       }
 }