r63232 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63231‎ | r63232 | r63233 >
Date:23:35, 3 March 2010
Author:mglaser
Status:deferred
Tags:
Comment:
- changed the order of prerequisite testing
- test now uploads the testimage into the wiki
- corrected test for too high page number
- corrected test for metadata extraction
Modified paths:
  • /trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php
@@ -26,16 +26,15 @@
2727 private $image;
2828 private $preCheckError;
2929
30 - function setUp()
 30+ function setUp($autoUpload = false)
3131 {
3232 global $wgTitle;
3333 $wgTitle = Title::newFromText("PagedTiffHandler_UnitTest");
3434
3535 $this->handler = new PagedTiffHandler();
36 - $this->image = wfFindFile(Title::newFromText('Image:Multipage.tiff'));
37 - if (!$this->image)
 36+ if (!file_exists( dirname(__FILE__) . '/testImages'))
3837 {
39 - echo "Please upload the image testImages/multipage.tiff into the wiki\n";
 38+ echo "testImages directory cannot be found.\n";
4039 $this->preCheckError = true;
4140 }
4241 if (!file_exists(dirname(__FILE__) . '/testImages/caspian.tif'))
@@ -48,12 +47,34 @@
4948 echo "testImages/Multipage.tif cannot be found.\n";
5049 $this->preCheckError = true;
5150 }
52 - if (!file_exists( dirname(__FILE__) . '/testImages'))
 51+ $multipageTitle = Title::newFromText('Image:Multipage.tiff');
 52+ $this->image = wfFindFile($multipageTitle);
 53+ if (!$this->image)
5354 {
54 - echo "testImages directory cannot be found.\n";
55 - $this->preCheckError = true;
 55+ if ($autoUpload)
 56+ {
 57+ echo "testImages/multipage.tiff seems not to be present in the wiki. Trying to upload.\n";
 58+ $this->image = wfLocalFile( $multipageTitle );
 59+ $archive = $this->image->publish( dirname(__FILE__) . '/testImages/multipage.tiff' );
 60+ $this->image->recordUpload( $archive->value, "Test file used for PagedTiffHandler unit test", "No license" );
 61+ if( WikiError::isError( $archive ) || !$archive->isGood() )
 62+ {
 63+ echo "Something went wrong. Please manually upload testImages/multipage.tiff\n";
 64+ $this->preCheckError = true;
 65+ }
 66+ else
 67+ {
 68+ echo "Upload was successful.\n";
 69+ }
 70+ }
 71+ else
 72+ {
 73+ echo "Please upload the image testImages/multipage.tiff into the wiki\n";
 74+ $this->preCheckError = true;
 75+ }
 76+
5677 }
57 -
 78+
5879 $this->path = dirname(__FILE__) . '/testImages/multipage.tiff';
5980 }
6081
@@ -106,8 +127,8 @@
107128 $this->assertEquals($this->handler->getPageDimensions( $this->image, 5 ), array('width' => 1024, 'height' => 768) );
108129 $this->assertEquals($this->handler->getPageDimensions( $this->image, 6 ), array('width' => 1024, 'height' => 768) );
109130 $this->assertEquals($this->handler->getPageDimensions( $this->image, 7 ), array('width' => 768, 'height' => 1024) );
110 - // TODO: check this, -1 is also false
111 - $this->assertEquals($this->handler->getPageDimensions( $this->image, 8 ), false );
 131+ // return dimensions of last page if page number is too high
 132+ $this->assertEquals($this->handler->getPageDimensions( $this->image, 8 ), array('width' => 768, 'height' => 1024) );
112133 // isMultiPage
113134 $this->assertTrue($this->handler->isMultiPage($this->image));
114135
@@ -119,9 +140,11 @@
120141 $this->assertTrue($this->handler->isMetadataValid($this->image, $metadata));
121142 // getMetaArray
122143 $metaArray = $this->handler->getMetaArray($this->image);
 144+
123145 $this->assertEquals($metaArray['Pages'], 7);
124 - $this->assertEquals($metaArray['pages'][1]['alpha'], 'False');
125 - $this->assertEquals($metaArray['pages'][2]['alpha'], 'True');
 146+ //this is also strtolower in PagedTiffHandler::getThumbExtension
 147+ $this->assertEquals(strtolower($metaArray['pages'][1]['alpha']), 'false');
 148+ $this->assertEquals(strtolower($metaArray['pages'][2]['alpha']), 'true');
126149 $this->assertEquals($metaArray['exif']['Endianess'], 'MSB');
127150 // formatMetadata
128151 $formattedMetadata = $this->handler->formatMetadata($this->image) ;
@@ -132,6 +155,6 @@
133156 $wgShowExceptionDetails = true;
134157
135158 $t = new PagedTiffHandlerTest();
136 -$t->setUp();
 159+$t->setUp(true);
137160 $t->runTest();
138161 ?>
\ No newline at end of file

Status & tagging log