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