5 class DjVuTest
extends MediaWikiMediaTestCase
{
12 protected function setUp() {
16 $djvuSupport = new DjVuSupport();
18 if ( !$djvuSupport->isEnabled() ) {
19 $this->markTestSkipped(
20 'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' );
23 $this->handler
= new DjVuHandler();
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'
34 public function testInvalidFile() {
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'
42 public function testPageCount() {
43 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
46 $this->handler
->pageCount( $file ),
47 'Test file LoremIpsum.djvu should be detected as containing 5 pages'
51 public function testGetPageDimensions() {
52 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
53 $this->assertArrayEquals(
55 $this->handler
->getPageDimensions( $file, 1 ),
56 'Page 1 of test file LoremIpsum.djvu should have a size of 2480 * 3508'
60 public function testGetPageText() {
61 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
64 (string) $this->handler
->getPageText( $file, 1 ),
65 "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"