| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Tests\Media; |
| 23 |
|
| 24 |
use BmpHandler; |
| 25 |
use File; |
| 26 |
use MediaHandlerState; |
| 27 |
use MediaWikiMediaTestCase; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class BmpHandlerTest extends MediaWikiMediaTestCase { |
| 34 |
|
| 35 |
protected BmpHandler $handler; |
| 36 |
protected File $tempFile; |
| 37 |
|
| 38 |
protected function setUp(): void { |
| 39 |
parent::setUp(); |
| 40 |
$this->handler = new BmpHandler(); |
| 41 |
$this->tempFile = $this->createMock( File::class ); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public function testMustRender() { |
| 48 |
$this->assertTrue( $this->handler->mustRender( $this->tempFile ) ); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public function testGetThumbType() { |
| 55 |
$this->assertEquals( [ 'png', 'image/png' ], $this->handler->getThumbType( 'bmp', 'image/bmp' ) ); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public function testGetSizeAndMetadata( string $filename, array $expected ) { |
| 63 |
$stateMock = $this->createMock( MediaHandlerState::class ); |
| 64 |
$res = $this->handler->getSizeAndMetadata( $stateMock, $filename ); |
| 65 |
$this->assertEquals( $expected, $res ); |
| 66 |
} |
| 67 |
|
| 68 |
public static function provideGetSizeAndMetadata(): array { |
| 69 |
return [ |
| 70 |
[ __DIR__ . '/../../data/media/bmp-100x100.bmp', [ 'width' => 100, 'height' => 100 ] ], |
| 71 |
[ __DIR__ . '/../../data/media/bmp-200x150.bmp', [ 'width' => 200, 'height' => 150 ] ], |
| 72 |
[ __DIR__ . '/../../data/media/bmp-300x200.bmp', [ 'width' => 300, 'height' => 200 ] ], |
| 73 |
]; |
| 74 |
} |
| 75 |
} |