Merge "resources: Strip '$' and 'mw' from file closures"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / FormatMetadataTest.php
index 3d0724f..e6d2b27 100644 (file)
@@ -33,7 +33,7 @@ class FormatMetadataTest extends MediaWikiMediaTestCase {
                $this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
                $this->assertEquals( '0000:01:00 00:02:27',
                        $meta['visible'][$dateIndex]['value'],
-                       'File with invalid date metadata (bug 29471)' );
+                       'File with invalid date metadata (T31471)' );
        }
 
        /**
@@ -44,7 +44,7 @@ class FormatMetadataTest extends MediaWikiMediaTestCase {
         */
        public function testResolveMultivalueValue( $input, $output ) {
                $formatMetadata = new FormatMetadata();
-               $class = new ReflectionClass( 'FormatMetadata' );
+               $class = new ReflectionClass( FormatMetadata::class );
                $method = $class->getMethod( 'resolveMultivalueValue' );
                $method->setAccessible( true );
                $actualInput = $method->invoke( $formatMetadata, $input );
@@ -95,4 +95,50 @@ class FormatMetadataTest extends MediaWikiMediaTestCase {
                        ],
                ];
        }
+
+       /**
+        * @param mixed $input
+        * @param mixed $output
+        * @dataProvider provideGetFormattedData
+        * @covers FormatMetadata::getFormattedData
+        */
+       public function testGetFormattedData( $input, $output ) {
+               $this->assertEquals( $output, FormatMetadata::getFormattedData( $input ) );
+       }
+
+       public function provideGetFormattedData() {
+               return [
+                       [
+                               [ 'Software' => 'Adobe Photoshop CS6 (Macintosh)' ],
+                               [ 'Software' => 'Adobe Photoshop CS6 (Macintosh)' ],
+                       ],
+                       [
+                               [ 'Software' => [ 'FotoWare FotoStation' ] ],
+                               [ 'Software' => 'FotoWare FotoStation' ],
+                       ],
+                       [
+                               [ 'Software' => [ [ 'Capture One PRO', '3.7.7' ] ] ],
+                               [ 'Software' => 'Capture One PRO (Version 3.7.7)' ],
+                       ],
+                       [
+                               [ 'Software' => [ [ 'FotoWare ColorFactory', '' ] ] ],
+                               [ 'Software' => 'FotoWare ColorFactory (Version )' ],
+                       ],
+                       [
+                               [ 'Software' => [ 'x-default' => 'paint.net 4.0.12', '_type' => 'lang' ] ],
+                               [ 'Software' => '<ul class="metadata-langlist">' .
+                                               '<li class="mw-metadata-lang-default">' .
+                                                       '<span class="mw-metadata-lang-value">paint.net 4.0.12</span>' .
+                                               "</li>\n" .
+                                       '</ul>'
+                               ],
+                       ],
+                       [
+                               // https://phabricator.wikimedia.org/T178130
+                               // WebMHandler.php turns both 'muxingapp' & 'writingapp' to 'Software'
+                               [ 'Software' => [ [ 'Lavf57.25.100' ], [ 'Lavf57.25.100' ] ] ],
+                               [ 'Software' => "<ul><li>Lavf57.25.100</li>\n<li>Lavf57.25.100</li></ul>" ],
+                       ],
+               ];
+       }
 }