wiki.techinc.nl/tests/phpunit/unit/includes/media/GIFMetadataExtractorTest.php
Umherirrender ea83138dcc tests: Declare GIFMetadataExtractorTest::$mediaPath
Creation of dynamic property GIFMetadataExtractorTest::$mediaPath is
deprecated in php8.2

Bug: T314099
Change-Id: I3247925a548586713d4363fc9e11625bc4c9ad46
2023-01-06 03:53:31 +01:00

122 lines
4.6 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @group Media
*/
class GIFMetadataExtractorTest extends \MediaWikiUnitTestCase {
/** @var string */
private $mediaPath;
protected function setUp(): void {
parent::setUp();
$this->mediaPath = __DIR__ . '/../../../data/media/';
}
/**
* Put in a file, and see if the metadata coming out is as expected.
* @param string $filename
* @param array $expected The extracted metadata.
* @dataProvider provideGetMetadata
* @covers GIFMetadataExtractor::getMetadata
*/
public function testGetMetadata( $filename, $expected ) {
$actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
$this->assertEquals( $expected, $actual );
}
public static function provideGetMetadata() {
$xmpNugget = <<<EOF
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 7.30'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about=''
xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
<Iptc4xmpCore:Location>The interwebs</Iptc4xmpCore:Location>
</rdf:Description>
<rdf:Description rdf:about=''
xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
<tiff:Artist>Bawolff</tiff:Artist>
<tiff:ImageDescription>
<rdf:Alt>
<rdf:li xml:lang='x-default'>A file to test GIF</rdf:li>
</rdf:Alt>
</tiff:ImageDescription>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>
EOF;
$xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
return [
[
'nonanimated.gif',
[
'width' => 45,
'height' => 30,
'bits' => 1,
'comment' => [ 'GIF test file ⁕ Created with GIMP' ],
'duration' => 0.1,
'frameCount' => 1,
'looped' => false,
'xmp' => '',
]
],
[
'animated.gif',
[
'width' => 45,
'height' => 30,
'bits' => 1,
'comment' => [ 'GIF test file . Created with GIMP' ],
'duration' => 2.4,
'frameCount' => 4,
'looped' => true,
'xmp' => '',
]
],
[
'animated-xmp.gif',
[
'width' => 45,
'height' => 30,
'bits' => 1,
'xmp' => $xmpNugget,
'duration' => 2.4,
'frameCount' => 4,
'looped' => true,
'comment' => [ 'GIƒ·test·file' ],
]
],
];
}
}