Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / media / DjVuTest.php
blobc0871f19fc39386755188aa90f37baa170587405
1 <?php
2 /**
3 * @group Media
4 * @covers DjVuHandler
5 */
6 class DjVuTest extends MediaWikiMediaTestCase {
8 /**
9 * @var DjVuHandler
11 protected $handler;
13 protected function setUp() {
14 parent::setUp();
16 //cli tool setup
17 $djvuSupport = new DjVuSupport();
19 if ( !$djvuSupport->isEnabled() ) {
20 $this->markTestSkipped(
21 'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' );
24 $this->handler = new DjVuHandler();
27 public function testGetImageSize() {
28 $this->assertArrayEquals(
29 array( 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'
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'
43 public function testPageCount() {
44 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
45 $this->assertEquals(
47 $this->handler->pageCount( $file ),
48 'Test file LoremIpsum.djvu should be detected as containing 5 pages'
52 public function testGetPageDimensions() {
53 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
54 $this->assertArrayEquals(
55 array( 2480, 3508 ),
56 $this->handler->getPageDimensions( $file, 1 ),
57 'Page 1 of test file LoremIpsum.djvu should have a size of 2480 * 3508'
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'"