diff options
Diffstat (limited to 'tests/phpunit/includes/media/FormatMetadataTest.php')
-rw-r--r-- | tests/phpunit/includes/media/FormatMetadataTest.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/phpunit/includes/media/FormatMetadataTest.php b/tests/phpunit/includes/media/FormatMetadataTest.php index 002e2cb9..54758f94 100644 --- a/tests/phpunit/includes/media/FormatMetadataTest.php +++ b/tests/phpunit/includes/media/FormatMetadataTest.php @@ -68,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' ), + ), + ); + } } |