5 class DjVuTest
extends MediaWikiTestCase
{
8 * @var string the directory where test files are
13 * @var FSRepo the repository to use
22 protected function setUp() {
26 $djvuSupport = new DjVuSupport();
28 if ( !$djvuSupport->isEnabled() ) {
29 $this->markTestSkipped( 'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' );
33 $this->filePath
= __DIR__
. '/../../data/media/';
34 $backend = new FSFileBackend( array(
35 'name' => 'localtesting',
36 'wikiId' => wfWikiId(),
37 'lockManager' => new NullLockManager( array() ),
38 'containerPaths' => array( 'data' => $this->filePath
)
40 $this->repo
= new FSRepo( array(
42 'url' => 'http://localhost/thumbtest',
46 $this->handler
= new DjVuHandler();
49 protected function dataFile( $name, $type ) {
50 return new UnregisteredLocalFile(
53 'mwstore://localtesting/data/' . $name,
58 public function testGetImageSize() {
59 $this->assertArrayEquals(
60 array( 2480, 3508, 'DjVu', 'width="2480" height="3508"' ),
61 $this->handler
->getImageSize( null, $this->filePath
. '/LoremIpsum.djvu' ),
62 'Test file LoremIpsum.djvu should have a size of 2480 * 3508'
66 public function testInvalidFile() {
68 $this->handler
->getMetadata( null, $this->filePath
. '/README' ),
69 'Getting Metadata for an inexistent file should returns false'
73 public function testPageCount() {
74 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
77 $this->handler
->pageCount( $file ),
78 'Test file LoremIpsum.djvu should be detected as containing 5 pages'
82 public function testGetPageDimensions() {
83 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
84 $this->assertArrayEquals(
86 $this->handler
->getPageDimensions( $file, 1 ),
87 'Page 1 of test file LoremIpsum.djvu should have a size of 2480 * 3508'
91 public function testGetPageText() {
92 $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' );
95 (string) $this->handler
->getPageText( $file, 1 ),
96 "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"