Debian Codegraph @

tests/phpunit/includes/media/BmpHandlerTest.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @since 1.42
20 */
21
22 namespace MediaWiki\Tests\Media;
23
24 use BmpHandler;
25 use File;
26 use MediaHandlerState;
27 use MediaWikiMediaTestCase;
28
29 /**
30 * @covers \BmpHandler
31 * @group Media
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 * @covers \BmpHandler::mustRender
46 */
47 public function testMustRender() {
48 $this->assertTrue( $this->handler->mustRender( $this->tempFile ) );
49 }
50
51 /**
52 * @covers \BmpHandler::getThumbType
53 */
54 public function testGetThumbType() {
55 $this->assertEquals( [ 'png', 'image/png' ], $this->handler->getThumbType( 'bmp', 'image/bmp' ) );
56 }
57
58 /**
59 * @covers \BmpHandler::getSizeAndMetadata
60 * @dataProvider provideGetSizeAndMetadata
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 }