Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/302218
Change subject: Skip tests related to DjVu reading when $wgDjvu* config parameters are not set ...................................................................... Skip tests related to DjVu reading when $wgDjvu* config parameters are not set So that it gracefully skip the tests instead of failing and triggering errors (respectively 6 and 3). Change-Id: Ieeaf900069aa93239a6b0450622c4808b34ffa0b --- M tests/includes/Pagination/FilePaginationTest.php M tests/includes/Pagination/PaginationFactoryTest.php M tests/includes/page/PageContentBuilderTest.php 3 files changed, 34 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage refs/changes/18/302218/1 diff --git a/tests/includes/Pagination/FilePaginationTest.php b/tests/includes/Pagination/FilePaginationTest.php index cd3e9c3..005554b 100644 --- a/tests/includes/Pagination/FilePaginationTest.php +++ b/tests/includes/Pagination/FilePaginationTest.php @@ -4,6 +4,7 @@ use File; use InvalidArgumentException; +use MediaHandler; use OutOfBoundsException; use ProofreadIndexPageTest; use ProofreadPagePage; @@ -17,6 +18,9 @@ class FilePaginationTest extends ProofreadPageTestCase { public function testGetPageNumber() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $pagination = new FilePagination( $index, @@ -34,6 +38,9 @@ * @dataProvider getPageNumberWithFailureProvider */ public function testGetPageNumberWithFailure( Pagination $pagination, ProofreadPagePage $page ) { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $pagination->getPageNumber( $page ); } @@ -61,6 +68,9 @@ } public function testGetDisplayedPageNumberBasic() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $pageNumber = new PageNumber( 'TOC' ); $pagination = new FilePagination( @@ -72,6 +82,9 @@ } public function testGetDisplayedPageNumberDefault() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $pageNumber = new PageNumber( 1 ); $pagination = new FilePagination( @@ -92,6 +105,9 @@ } public function testGetNumberOfPages() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $pagination = new FilePagination( $index, new PageList( [] ), @@ -102,6 +118,9 @@ } public function testGetPage() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $page = new ProofreadPagePage( Title::makeTitle( 250, 'LoremIpsum.djvu/2' ), $index ); $pagination = new FilePagination( @@ -116,6 +135,9 @@ * @expectedException OutOfBoundsException */ public function testGetPageWithFailure() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $pagination = new FilePagination( $index, new PageList( [] ), @@ -126,6 +148,9 @@ } public function testIterator() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $index = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu' ); $page1 = new ProofreadPagePage( Title::makeTitle( 250, 'LoremIpsum.djvu/1' ), $index ); $page2 = new ProofreadPagePage( Title::makeTitle( 250, 'LoremIpsum.djvu/2' ), $index ); diff --git a/tests/includes/Pagination/PaginationFactoryTest.php b/tests/includes/Pagination/PaginationFactoryTest.php index 181574e..eb23bba 100644 --- a/tests/includes/Pagination/PaginationFactoryTest.php +++ b/tests/includes/Pagination/PaginationFactoryTest.php @@ -2,6 +2,7 @@ namespace ProofreadPage\Pagination; +use MediaHandler; use ProofreadIndexPageTest; use ProofreadPagePage; use ProofreadPageTestCase; @@ -14,6 +15,9 @@ class PaginationFactoryTest extends ProofreadPageTestCase { public function testGetPaginationWithPagelist() { + if ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $page = ProofreadIndexPageTest::newIndexPage( 'LoremIpsum.djvu', "{{\n|Pages=<pagelist 1to2=-/> <pagelist 3=1 4to5=roman />\n|Author=[[Author:Me]]\n}}" ); $pageList = new PageList( [ '1to2' => '-', '3' => '1', '4to5' => 'roman' ] ); $pagination = new FilePagination( diff --git a/tests/includes/page/PageContentBuilderTest.php b/tests/includes/page/PageContentBuilderTest.php index e7fa8bf..f6d2ee5 100644 --- a/tests/includes/page/PageContentBuilderTest.php +++ b/tests/includes/page/PageContentBuilderTest.php @@ -3,6 +3,7 @@ namespace ProofreadPage\Page; use IContextSource; +use MediaHandler; use ProofreadIndexPageTest; use ProofreadPagePage; use ProofreadPagePageTest; @@ -32,6 +33,10 @@ * @dataProvider buildDefaultContentForPageProvider */ public function testBuildDefaultContentForPage( ProofreadPagePage $page, PageContent $defaultContent ) { + global $wgDjvuTxt; + if ( $defaultContent->getHeader()->getNativeData() != 'Test book' && ( MediaHandler::getHandler( 'image/vnd.djvu' ) === false || !isset( $wgDjvuTxt ) ) ) { + $this->markTestSkipped( 'There is no support for DjVu files, please enable it.' ); + } $contentBuilder = new PageContentBuilder( $this->context, $this->getContext() ); $this->assertEquals( $defaultContent, $contentBuilder->buildDefaultContentForPage( $page ) ); } -- To view, visit https://gerrit.wikimedia.org/r/302218 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieeaf900069aa93239a6b0450622c4808b34ffa0b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ProofreadPage Gerrit-Branch: master Gerrit-Owner: Seb35 <seb35wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits