Index: trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php |
— | — | @@ -45,6 +45,35 @@ |
46 | 46 | echo "testImages/Multipage.tif cannot be found.\n"; |
47 | 47 | $this->preCheckError = true; |
48 | 48 | } |
| 49 | + |
| 50 | + $caspianTitle = Title::newFromText('Image:Caspian.tif'); |
| 51 | + $this->image = wfFindFile($caspianTitle); |
| 52 | + if (!$this->image) |
| 53 | + { |
| 54 | + if ($autoUpload) |
| 55 | + { |
| 56 | + echo "testImages/caspian.tif seems not to be present in the wiki. Trying to upload.\n"; |
| 57 | + $this->image = wfLocalFile( $caspianTitle ); |
| 58 | + $archive = $this->image->publish( dirname(__FILE__) . '/testImages/caspian.tif' ); |
| 59 | + $this->image->recordUpload( $archive->value, "Test file used for PagedTiffHandler unit test", "No license" ); |
| 60 | + if( WikiError::isError( $archive ) || !$archive->isGood() ) |
| 61 | + { |
| 62 | + echo "Something went wrong. Please manually upload testImages/caspian.tif\n"; |
| 63 | + $this->preCheckError = true; |
| 64 | + } |
| 65 | + else |
| 66 | + { |
| 67 | + echo "Upload was successful.\n"; |
| 68 | + } |
| 69 | + } |
| 70 | + else |
| 71 | + { |
| 72 | + echo "Please upload the image testImages/caspian.tif into the wiki\n"; |
| 73 | + $this->preCheckError = true; |
| 74 | + } |
| 75 | + |
| 76 | + } |
| 77 | + |
49 | 78 | $multipageTitle = Title::newFromText( 'Image:Multipage.tiff' ); |
50 | 79 | $this->image = wfFindFile( $multipageTitle ); |
51 | 80 | if ( !$this->image ) { |
— | — | @@ -70,6 +99,7 @@ |
71 | 100 | } |
72 | 101 | |
73 | 102 | function runTest() { |
| 103 | + global $wgLanguageCode; |
74 | 104 | // do not execute test if preconditions check returned false; |
75 | 105 | if ( $this->preCheckError ) { |
76 | 106 | return false; |
— | — | @@ -87,6 +117,13 @@ |
88 | 118 | $params = array( 'width' => '100', 'height' => '100', 'page' => '4' ); |
89 | 119 | $this->handler->normaliseParams( $this->image, $params ); |
90 | 120 | $this->assertEquals( $params['height'], 75 ); |
| 121 | + // lossy and lossless |
| 122 | + $params = array('width'=>'100', 'height'=>'100', 'page'=>'1'); |
| 123 | + $this->handler->normaliseParams($this->image, $params ); |
| 124 | + $this->assertEquals($params['lossy'], '1'); |
| 125 | + $params = array('width'=>'100', 'height'=>'100', 'page'=>'2'); |
| 126 | + $this->handler->normaliseParams($this->image, $params ); |
| 127 | + $this->assertEquals($params['lossy'], '0'); |
91 | 128 | // makeParamString |
92 | 129 | $this->assertEquals( |
93 | 130 | $this->handler->makeParamString( |
— | — | @@ -98,12 +135,10 @@ |
99 | 136 | ), |
100 | 137 | 'lossless-page4-100px' |
101 | 138 | ); |
102 | | - |
103 | 139 | // ---- File upload checks and Thumbnail transformation |
104 | 140 | // check |
105 | 141 | // TODO: check other images |
106 | 142 | $this->assertTrue( $this->handler->check( 'multipage.tiff', $this->path, $error ) ); |
107 | | - |
108 | 143 | $this->handler->check( 'Caspian.tif', dirname( __FILE__ ) . '/testImages/caspian.tif', $error ); |
109 | 144 | $this->assertEquals( $error, 'tiff_bad_file' ); |
110 | 145 | // doTransform |
— | — | @@ -116,7 +151,12 @@ |
117 | 152 | // TODO: 0 is obviously the same as NULL |
118 | 153 | $this->assertEquals( $this->handler->getThumbExtension( $this->image, 2, '0' ), '.png' ); |
119 | 154 | // getLongDesc |
120 | | - $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1.024', '768', '2,64 MB', 'image/tiff', '1' ) ); |
| 155 | + if ( $wgLanguageCode == 'de' ) { |
| 156 | + $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1.024', '768', '2,64 MB', 'image/tiff', '1' ) ); |
| 157 | + } else { |
| 158 | + // English |
| 159 | + $this->assertEquals( $this->handler->getLongDesc( $this->image ), wfMsg( 'tiff-file-info-size', '1,024', '768', '2.64 MB', 'image/tiff', '1' ) ); |
| 160 | + } |
121 | 161 | // pageCount |
122 | 162 | $this->assertEquals( $this->handler->pageCount( $this->image ), 7 ); |
123 | 163 | // getPageDimensions |
— | — | @@ -132,7 +172,7 @@ |
133 | 173 | $this->assertEquals( $this->handler->getPageDimensions( $this->image, 8 ), array( 'width' => 768, 'height' => 1024 ) ); |
134 | 174 | // isMultiPage |
135 | 175 | $this->assertTrue( $this->handler->isMultiPage( $this->image ) ); |
136 | | - |
| 176 | + |
137 | 177 | // ---- Metadata handling |
138 | 178 | // getMetadata |
139 | 179 | $metadata = $this->handler->getMetadata( false, $this->path ); |