Remove messages.inc, rebuildLanguage.php, writeMessagesArray.inc
[mediawiki.git] / tests / phpunit / includes / media / DjVuTest.php
blob537c124d61758754b93c3169772bddbfef65de4e
1 <?php
2 /**
3 * @covers DjVuHandler
4 */
5 class DjVuTest extends MediaWikiTestCase {
7 /**
8 * @var string the directory where test files are
9 */
10 protected $filePath;
12 /**
13 * @var FSRepo the repository to use
15 protected $repo;
17 /**
18 * @var DjVuHandler
20 protected $handler;
22 protected function setUp() {
23 parent::setUp();
25 //cli tool setup
26 $djvuSupport = new DjVuSupport();
28 if ( !$djvuSupport->isEnabled() ) {
29 $this->markTestSkipped( 'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' );
32 //file repo setup
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 )
39 ) );
40 $this->repo = new FSRepo( array(
41 'name' => 'temp',
42 'url' => 'http://localhost/thumbtest',
43 'backend' => $backend
44 ) );
46 $this->handler = new DjVuHandler();
49 protected function dataFile( $name, $type ) {
50 return new UnregisteredLocalFile(
51 false,
52 $this->repo,
53 'mwstore://localtesting/data/' . $name,
54 $type
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() {
67 $this->assertFalse(
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' );
75 $this->assertEquals(
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(
85 array( 2480, 3508 ),
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' );
93 $this->assertEquals(
94 "Lorem ipsum \n1 \n",
95 (string) $this->handler->getPageText( $file, 1 ),
96 "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'"