Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @covers Jpeg2000Handler
|
|
*/
|
|
class Jpeg2000HandlerTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/** @var string */
|
|
private $tempFileName;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
// Allocated file for testing
|
|
$this->tempFileName = tempnam( wfTempDir(), 'JPEG2000' );
|
|
}
|
|
|
|
protected function tearDown(): void {
|
|
unlink( $this->tempFileName );
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideTestGetSizeAndMetadata
|
|
*/
|
|
public function testGetSizeAndMetadata( $path, $expectedResult ) {
|
|
$handler = new Jpeg2000Handler();
|
|
$this->assertEquals( $expectedResult, $handler->getSizeAndMetadata(
|
|
new TrivialMediaHandlerState, $path ) );
|
|
}
|
|
|
|
public static function provideTestGetSizeAndMetadata() {
|
|
return [
|
|
[ __DIR__ . '/../../data/media/jpeg2000-lossless.jp2', [
|
|
'width' => 100,
|
|
'height' => 100,
|
|
'bits' => 8,
|
|
] ],
|
|
[ __DIR__ . '/../../data/media/jpeg2000-lossy.jp2', [
|
|
'width' => 100,
|
|
'height' => 100,
|
|
'bits' => 8,
|
|
] ],
|
|
[ __DIR__ . '/../../data/media/jpeg2000-alpha.jp2', [
|
|
'width' => 100,
|
|
'height' => 100,
|
|
'bits' => 8,
|
|
] ],
|
|
[ __DIR__ . '/../../data/media/jpeg2000-profile.jpf', [
|
|
'width' => 100,
|
|
'height' => 100,
|
|
'bits' => 8,
|
|
] ],
|
|
|
|
// Error cases
|
|
[ __FILE__, [] ],
|
|
];
|
|
}
|
|
}
|