Add @covers tags to media tests
[lhc/web/wiklou.git] / tests / phpunit / includes / media / DjVuTest.php
1 <?php
2 /**
3 * @group Media
4 * @covers DjVuHandler
5 */
6 class DjVuTest extends MediaWikiMediaTestCase {
7
8 /**
9 * @var DjVuHandler
10 */
11 protected $handler;
12
13 protected function setUp() {
14 parent::setUp();
15
16 // cli tool setup
17 $djvuSupport = new DjVuSupport();
18
19 if ( !$djvuSupport->isEnabled() ) {
20 $this->markTestSkipped(
21 'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' );
22 }
23
24 $this->handler = new DjVuHandler();
25 }
26
27 public function testGetImageSize() {
28 $this->assertArrayEquals(
29 [ 2480, 3508, 'DjVu', 'width="2480" height="3508"' ],
30 $this->handler->getImageSize( null, $this->filePath . '/LoremIpsum.djvu' ),
31 'Test file LoremIpsum.djvu should have a size of 2480 * 3508'
32 );
33 }
34
35 public function testInvalidFile() {
36 $this->assertEquals(
37 'a:1:{s:5:"error";s:25:"Error extracting metadata";}',
38 $this->handler->getMetadata( null, $this->filePath . '/some-nonexistent-file' ),
39 'Getting metadata for an inexistent file should return false'
40 );
41 }
42
43 public function testPageCount() {
44 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
45 $this->assertEquals(
46 5,
47 $this->handler->pageCount( $file ),
48 'Test file LoremIpsum.djvu should be detected as containing 5 pages'
49 );
50 }
51
52 public function testGetPageDimensions() {
53 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
54 $this->assertArrayEquals(
55 [ 2480, 3508 ],
56 $this->handler->getPageDimensions( $file, 1 ),
57 'Page 1 of test file LoremIpsum.djvu should have a size of 2480 * 3508'
58 );
59 }
60
61 public function testGetPageText() {
62 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
63 $this->assertEquals(
64 "Lorem ipsum \n1 \n",
65 (string)$this->handler->getPageText( $file, 1 ),
66 "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"
67 );
68 }
69 }