http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68347
Revision: 68347 Author: mglaser Date: 2010-06-21 10:23:13 +0000 (Mon, 21 Jun 2010) Log Message: ----------- * tests for lossiness in thumb file names * check if caspian.tif ist uploaded * make tests run with de and en locale Modified Paths: -------------- trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php Modified: trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php =================================================================== --- trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php 2010-06-21 10:19:40 UTC (rev 68346) +++ trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php 2010-06-21 10:23:13 UTC (rev 68347) @@ -45,6 +45,35 @@ echo "testImages/Multipage.tif cannot be found.\n"; $this->preCheckError = true; } + + $caspianTitle = Title::newFromText('Image:Caspian.tif'); + $this->image = wfFindFile($caspianTitle); + if (!$this->image) + { + if ($autoUpload) + { + echo "testImages/caspian.tif seems not to be present in the wiki. Trying to upload.\n"; + $this->image = wfLocalFile( $caspianTitle ); + $archive = $this->image->publish( dirname(__FILE__) . '/testImages/caspian.tif' ); + $this->image->recordUpload( $archive->value, "Test file used for PagedTiffHandler unit test", "No license" ); + if( WikiError::isError( $archive ) || !$archive->isGood() ) + { + echo "Something went wrong. Please manually upload testImages/caspian.tif\n"; + $this->preCheckError = true; + } + else + { + echo "Upload was successful.\n"; + } + } + else + { + echo "Please upload the image testImages/caspian.tif into the wiki\n"; + $this->preCheckError = true; + } + + } + $multipageTitle = Title::newFromText( 'Image:Multipage.tiff' ); $this->image = wfFindFile( $multipageTitle ); if ( !$this->image ) { @@ -70,6 +99,7 @@ } function runTest() { + global $wgLanguageCode; // do not execute test if preconditions check returned false; if ( $this->preCheckError ) { return false; @@ -87,6 +117,13 @@ $params = array( 'width' => '100', 'height' => '100', 'page' => '4' ); $this->handler->normaliseParams( $this->image, $params ); $this->assertEquals( $params['height'], 75 ); + // lossy and lossless + $params = array('width'=>'100', 'height'=>'100', 'page'=>'1'); + $this->handler->normaliseParams($this->image, $params ); + $this->assertEquals($params['lossy'], '1'); + $params = array('width'=>'100', 'height'=>'100', 'page'=>'2'); + $this->handler->normaliseParams($this->image, $params ); + $this->assertEquals($params['lossy'], '0'); // makeParamString $this->assertEquals( $this->handler->makeParamString( @@ -98,12 +135,10 @@ ), 'lossless-page4-100px' ); - // ---- File upload checks and Thumbnail transformation // check // TODO: check other images $this->assertTrue( $this->handler->check( 'multipage.tiff', $this->path, $error ) ); - $this->handler->check( 'Caspian.tif', dirname( __FILE__ ) . '/testImages/caspian.tif', $error ); $this->assertEquals( $error, 'tiff_bad_file' ); // doTransform @@ -116,7 +151,12 @@ // TODO: 0 is obviously the same as NULL $this->assertEquals( $this->handler->getThumbExtension( $this->image, 2, '0' ), '.png' ); // getLongDesc - $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1.024', '768', '2,64 MB', 'image/tiff', '1' ) ); + if ( $wgLanguageCode == 'de' ) { + $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1.024', '768', '2,64 MB', 'image/tiff', '1' ) ); + } else { + // English + $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1,024', '768', '2.64 MB', 'image/tiff', '1' ) ); + } // pageCount $this->assertEquals( $this->handler->pageCount( $this->image ), 7 ); // getPageDimensions @@ -132,7 +172,7 @@ $this->assertEquals( $this->handler->getPageDimensions( $this->image, 8 ), array( 'width' => 768, 'height' => 1024 ) ); // isMultiPage $this->assertTrue( $this->handler->isMultiPage( $this->image ) ); - + // ---- Metadata handling // getMetadata $metadata = $this->handler->getMetadata( false, $this->path ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs