From 14f74d141ab5580688bfd46d2f74c026e43ed967 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 1 Apr 2015 06:11:44 +0200 Subject: Update to MediaWiki 1.24.2 --- tests/phpunit/includes/media/DjVuTest.php | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/phpunit/includes/media/DjVuTest.php (limited to 'tests/phpunit/includes/media/DjVuTest.php') diff --git a/tests/phpunit/includes/media/DjVuTest.php b/tests/phpunit/includes/media/DjVuTest.php new file mode 100644 index 00000000..c0871f19 --- /dev/null +++ b/tests/phpunit/includes/media/DjVuTest.php @@ -0,0 +1,69 @@ +isEnabled() ) { + $this->markTestSkipped( + 'This test needs the installation of the ddjvu, djvutoxml and djvudump tools' ); + } + + $this->handler = new DjVuHandler(); + } + + public function testGetImageSize() { + $this->assertArrayEquals( + array( 2480, 3508, 'DjVu', 'width="2480" height="3508"' ), + $this->handler->getImageSize( null, $this->filePath . '/LoremIpsum.djvu' ), + 'Test file LoremIpsum.djvu should have a size of 2480 * 3508' + ); + } + + public function testInvalidFile() { + $this->assertEquals( + 'a:1:{s:5:"error";s:25:"Error extracting metadata";}', + $this->handler->getMetadata( null, $this->filePath . '/some-nonexistent-file' ), + 'Getting metadata for an inexistent file should return false' + ); + } + + public function testPageCount() { + $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' ); + $this->assertEquals( + 5, + $this->handler->pageCount( $file ), + 'Test file LoremIpsum.djvu should be detected as containing 5 pages' + ); + } + + public function testGetPageDimensions() { + $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' ); + $this->assertArrayEquals( + array( 2480, 3508 ), + $this->handler->getPageDimensions( $file, 1 ), + 'Page 1 of test file LoremIpsum.djvu should have a size of 2480 * 3508' + ); + } + + public function testGetPageText() { + $file = $this->dataFile( 'LoremIpsum.djvu', 'image/x.djvu' ); + $this->assertEquals( + "Lorem ipsum \n1 \n", + (string)$this->handler->getPageText( $file, 1 ), + "Text layer of page 1 of file LoremIpsum.djvu should be 'Lorem ipsum \n1 \n'" + ); + } +} -- cgit v1.2.3-54-g00ecf