6 class DjVuTest
extends MediaWikiMediaTestCase
{
13 protected function 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() {
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' );
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(
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' );
65 (string)$this->handler
->getPageText( $file, 1 ),
66 "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"