MediaWiki  REL1_24
DjVuTest.php
Go to the documentation of this file.
00001 <?php
00006 class DjVuTest extends MediaWikiMediaTestCase {
00007 
00011     protected $handler;
00012 
00013     protected function setUp() {
00014         parent::setUp();
00015 
00016         //cli tool setup
00017         $djvuSupport = new DjVuSupport();
00018 
00019         if ( !$djvuSupport->isEnabled() ) {
00020             $this->markTestSkipped(
00021             'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' );
00022         }
00023 
00024         $this->handler = new DjVuHandler();
00025     }
00026 
00027     public function testGetImageSize() {
00028         $this->assertArrayEquals(
00029             array( 2480, 3508, 'DjVu', 'width="2480" height="3508"' ),
00030             $this->handler->getImageSize( null, $this->filePath . '/LoremIpsum.djvu' ),
00031             'Test file LoremIpsum.djvu should have a size of 2480 * 3508'
00032         );
00033     }
00034 
00035     public function testInvalidFile() {
00036         $this->assertEquals(
00037             'a:1:{s:5:"error";s:25:"Error extracting metadata";}',
00038             $this->handler->getMetadata( null, $this->filePath . '/some-nonexistent-file' ),
00039             'Getting metadata for an inexistent file should return false'
00040         );
00041     }
00042 
00043     public function testPageCount() {
00044         $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
00045         $this->assertEquals(
00046             5,
00047             $this->handler->pageCount( $file ),
00048             'Test file LoremIpsum.djvu should be detected as containing 5 pages'
00049         );
00050     }
00051 
00052     public function testGetPageDimensions() {
00053         $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
00054         $this->assertArrayEquals(
00055             array( 2480, 3508 ),
00056             $this->handler->getPageDimensions( $file, 1 ),
00057             'Page 1 of test file LoremIpsum.djvu should have a size of 2480 * 3508'
00058         );
00059     }
00060 
00061     public function testGetPageText() {
00062         $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
00063         $this->assertEquals(
00064             "Lorem ipsum \n1 \n",
00065             (string)$this->handler->getPageText( $file, 1 ),
00066             "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"
00067         );
00068     }
00069 }