Update formatting
5 of n. Change-Id: I811ca957b6588085d67606ebc0cd4033a1e53839
This commit is contained in:
parent
fdef79d9f2
commit
de04f37ef1
25 changed files with 214 additions and 167 deletions
|
|
@ -8,12 +8,14 @@ class FileRepoTest extends MediaWikiTestCase {
|
|||
function testFileRepoConstructionOptionCanNotBeNull() {
|
||||
$f = new FileRepo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
*/
|
||||
function testFileRepoConstructionOptionCanNotBeAnEmptyArray() {
|
||||
$f = new FileRepo( array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
*/
|
||||
|
|
@ -22,6 +24,7 @@ class FileRepoTest extends MediaWikiTestCase {
|
|||
'backend' => 'foobar'
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
*/
|
||||
|
|
@ -33,10 +36,10 @@ class FileRepoTest extends MediaWikiTestCase {
|
|||
|
||||
function testFileRepoConstructionWithRequiredOptions() {
|
||||
$f = new FileRepo( array(
|
||||
'name' => 'FileRepoTestRepository',
|
||||
'name' => 'FileRepoTestRepository',
|
||||
'backend' => new FSFileBackend( array(
|
||||
'name' => 'local-testing',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'name' => 'local-testing',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'containerPaths' => array()
|
||||
) )
|
||||
) );
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ class StoreBatchTest extends MediaWikiTestCase {
|
|||
$backend = new $class( $useConfig );
|
||||
} else {
|
||||
$backend = new FSFileBackend( array(
|
||||
'name' => 'local-testing',
|
||||
'name' => 'local-testing',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'containerPaths' => array(
|
||||
'unittests-public' => "{$tmpPrefix}-public",
|
||||
'unittests-thumb' => "{$tmpPrefix}-thumb",
|
||||
'unittests-temp' => "{$tmpPrefix}-temp",
|
||||
'unittests-public' => "{$tmpPrefix}-public",
|
||||
'unittests-thumb' => "{$tmpPrefix}-thumb",
|
||||
'unittests-temp' => "{$tmpPrefix}-temp",
|
||||
'unittests-deleted' => "{$tmpPrefix}-deleted",
|
||||
)
|
||||
) );
|
||||
}
|
||||
$this->repo = new FileRepo( array(
|
||||
'name' => 'unittests',
|
||||
'name' => 'unittests',
|
||||
'backend' => $backend
|
||||
) );
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ class StoreBatchTest extends MediaWikiTestCase {
|
|||
* @param $srcPath string The filepath or virtual URL
|
||||
* @param $flags integer Flags to pass into repo::store().
|
||||
*/
|
||||
private function storeit($originalName, $srcPath, $flags) {
|
||||
private function storeit( $originalName, $srcPath, $flags ) {
|
||||
$hashPath = $this->repo->getHashPath( $originalName );
|
||||
$dstRel = "$hashPath{$this->date}!$originalName";
|
||||
$dstUrlRel = $hashPath . $this->date . '!' . rawurlencode( $originalName );
|
||||
|
|
@ -80,13 +80,13 @@ class StoreBatchTest extends MediaWikiTestCase {
|
|||
* @param $otherfn string The name of the different file (in the filesystem)
|
||||
* @param $fromrepo logical 'true' if we want to copy from a virtual URL out of the Repo.
|
||||
*/
|
||||
private function storecohort($fn, $infn, $otherfn, $fromrepo) {
|
||||
private function storecohort( $fn, $infn, $otherfn, $fromrepo ) {
|
||||
$f = $this->storeit( $fn, $infn, 0 );
|
||||
$this->assertTrue( $f->isOK(), 'failed to store a new file' );
|
||||
$this->assertEquals( $f->failCount, 0, "counts wrong {$f->successCount} {$f->failCount}" );
|
||||
$this->assertEquals( $f->successCount, 1, "counts wrong {$f->successCount} {$f->failCount}" );
|
||||
if ( $fromrepo ) {
|
||||
$f = $this->storeit( "Other-$fn", $infn, FileRepo::OVERWRITE);
|
||||
$f = $this->storeit( "Other-$fn", $infn, FileRepo::OVERWRITE );
|
||||
$infn = $f->value;
|
||||
}
|
||||
// This should work because we're allowed to overwrite
|
||||
|
|
@ -106,7 +106,7 @@ class StoreBatchTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( $f->successCount, 1, "counts wrong {$f->successCount} {$f->failCount}" );
|
||||
// This should fail because we're overwriting different content.
|
||||
if ( $fromrepo ) {
|
||||
$f = $this->storeit( "Other-$fn", $otherfn, FileRepo::OVERWRITE);
|
||||
$f = $this->storeit( "Other-$fn", $otherfn, FileRepo::OVERWRITE );
|
||||
$otherfn = $f->value;
|
||||
}
|
||||
$f = $this->storeit( $fn, $otherfn, FileRepo::OVERWRITE_SAME );
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@ class InstallDocFormatterTest extends MediaWikiTestCase {
|
|||
# Format: (expected string, unformattedText string, optional message)
|
||||
return array(
|
||||
# Escape some wikitext
|
||||
array( 'Install <tag>' , 'Install <tag>', 'Escaping <' ),
|
||||
array( 'Install {{template}}' , 'Install {{template}}', 'Escaping [[' ),
|
||||
array( 'Install [[page]]' , 'Install [[page]]', 'Escaping {{' ),
|
||||
array( 'Install ' , "Install \r", 'Removing \r' ),
|
||||
array( 'Install <tag>', 'Install <tag>', 'Escaping <' ),
|
||||
array( 'Install {{template}}', 'Install {{template}}', 'Escaping [[' ),
|
||||
array( 'Install [[page]]', 'Install [[page]]', 'Escaping {{' ),
|
||||
array( 'Install ', "Install \r", 'Removing \r' ),
|
||||
|
||||
# Transform \t{1,2} into :{1,2}
|
||||
array( ':One indentation', "\tOne indentation", 'Replacing a single \t' ),
|
||||
array( '::Two indentations', "\t\tTwo indentations", 'Replacing 2 x \t' ),
|
||||
|
||||
# Transform 'bug 123' links
|
||||
array(
|
||||
array(
|
||||
'<span class="config-plainlink">[https://bugzilla.wikimedia.org/123 bug 123]</span>',
|
||||
'bug 123', 'Testing bug 123 links' ),
|
||||
array(
|
||||
|
|
@ -55,7 +55,7 @@ class InstallDocFormatterTest extends MediaWikiTestCase {
|
|||
array(
|
||||
'<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:$wgFoo_Bar $wgFoo_Bar]</span>',
|
||||
'$wgFoo_Bar', 'Testing $wgFoo_Bar (with underscore)' ),
|
||||
|
||||
|
||||
# Icky variables that shouldn't link
|
||||
array( '$myAwesomeVariable', '$myAwesomeVariable', 'Testing $myAwesomeVariable (not starting with $wg)' ),
|
||||
array( '$()not!a&Var', '$()not!a&Var', 'Testing $()not!a&Var (obviously not a variable)' ),
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
foreach ( array( 'queueRand', 'queueRandTTL', 'queueFifo', 'queueFifoTTL' ) as $q ) {
|
||||
do {
|
||||
$job = $this->$q->pop();
|
||||
if ( $job ) $this->$q->ack( $job );
|
||||
if ( $job ) {
|
||||
$this->$q->ack( $job );
|
||||
}
|
||||
} while ( $job );
|
||||
}
|
||||
$this->queueRand = null;
|
||||
|
|
@ -127,7 +129,7 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
|
||||
|
||||
$this->assertTrue( $queue->batchPush(
|
||||
array( $this->newDedupedJob(), $this->newDedupedJob(), $this->newDedupedJob() ) ),
|
||||
array( $this->newDedupedJob(), $this->newDedupedJob(), $this->newDedupedJob() ) ),
|
||||
"Push worked ($desc)" );
|
||||
|
||||
$this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" );
|
||||
|
|
@ -137,7 +139,7 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
|
||||
|
||||
$this->assertTrue( $queue->batchPush(
|
||||
array( $this->newDedupedJob(), $this->newDedupedJob(), $this->newDedupedJob() ) ),
|
||||
array( $this->newDedupedJob(), $this->newDedupedJob(), $this->newDedupedJob() ) ),
|
||||
"Push worked ($desc)" );
|
||||
|
||||
$this->assertFalse( $queue->isEmpty(), "Queue is not empty ($desc)" );
|
||||
|
|
@ -177,7 +179,7 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
|
||||
$id = wfRandomString( 32 );
|
||||
$root1 = Job::newRootJobParams( "nulljobspam:$id" ); // task ID/timestamp
|
||||
for ( $i=0; $i<5; ++$i ) {
|
||||
for ( $i = 0; $i < 5; ++$i ) {
|
||||
$this->assertTrue( $queue->push( $this->newJob( 0, $root1 ) ), "Push worked ($desc)" );
|
||||
}
|
||||
$queue->deduplicateRootJob( $this->newJob( 0, $root1 ) );
|
||||
|
|
@ -185,7 +187,7 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
$root2 = Job::newRootJobParams( "nulljobspam:$id" ); // task ID/timestamp
|
||||
$this->assertNotEquals( $root1['rootJobTimestamp'], $root2['rootJobTimestamp'],
|
||||
"Root job signatures have different timestamps." );
|
||||
for ( $i=0; $i<5; ++$i ) {
|
||||
for ( $i = 0; $i < 5; ++$i ) {
|
||||
$this->assertTrue( $queue->push( $this->newJob( 0, $root2 ) ), "Push worked ($desc)" );
|
||||
}
|
||||
$queue->deduplicateRootJob( $this->newJob( 0, $root2 ) );
|
||||
|
|
@ -204,7 +206,9 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
$jobs[] = $job;
|
||||
$queue->ack( $job );
|
||||
}
|
||||
if ( $job instanceof DuplicateJob ) ++$dupcount;
|
||||
if ( $job instanceof DuplicateJob ) {
|
||||
++$dupcount;
|
||||
}
|
||||
} while ( $job );
|
||||
|
||||
$this->assertEquals( 10, count( $jobs ), "Correct number of jobs popped ($desc)" );
|
||||
|
|
@ -223,11 +227,11 @@ class JobQueueTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
|
||||
$this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
|
||||
|
||||
for ( $i=0; $i<10; ++$i ) {
|
||||
for ( $i = 0; $i < 10; ++$i ) {
|
||||
$this->assertTrue( $queue->push( $this->newJob( $i ) ), "Push worked ($desc)" );
|
||||
}
|
||||
|
||||
for ( $i=0; $i<10; ++$i ) {
|
||||
for ( $i = 0; $i < 10; ++$i ) {
|
||||
$job = $queue->pop();
|
||||
$this->assertTrue( $job instanceof Job, "Jobs popped from queue ($desc)" );
|
||||
$params = $job->getParams();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class ServicesJsonTest extends MediaWikiTestCase {
|
|||
if ( !function_exists( 'json_encode' ) ) {
|
||||
$this->markTestIncomplete( 'No PHP json support, unable to test' );
|
||||
return;
|
||||
} elseif( strtolower( json_encode( "\xf0\xa0\x80\x80" ) ) != '"\ud840\udc00"' ) {
|
||||
} elseif ( strtolower( json_encode( "\xf0\xa0\x80\x80" ) ) != '"\ud840\udc00"' ) {
|
||||
$this->markTestIncomplete( 'Have buggy PHP json support, unable to test' );
|
||||
return;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,10 +17,9 @@ class CSSJanusTest extends MediaWikiTestCase {
|
|||
|
||||
$transformedB = CSSJanus::transform( $cssB );
|
||||
$this->assertEquals( $transformedB, $cssA, 'Test B-A transformation' );
|
||||
|
||||
// If no B version is provided, it means
|
||||
// the output should equal the input.
|
||||
} else {
|
||||
// If no B version is provided, it means
|
||||
// the output should equal the input.
|
||||
$transformedA = CSSJanus::transform( $cssA );
|
||||
$this->assertEquals( $transformedA, $cssA, 'Nothing was flipped' );
|
||||
}
|
||||
|
|
@ -36,10 +35,11 @@ class CSSJanusTest extends MediaWikiTestCase {
|
|||
$flipped = CSSJanus::transform( $code, $swapLtrRtlInURL, $swapLeftRightInURL );
|
||||
|
||||
$this->assertEquals( $expectedOutput, $flipped,
|
||||
'Test flipping, options: url-ltr-rtl=' . ($swapLtrRtlInURL ? 'true' : 'false')
|
||||
. ' url-left-right=' . ($swapLeftRightInURL ? 'true' : 'false')
|
||||
'Test flipping, options: url-ltr-rtl=' . ( $swapLtrRtlInURL ? 'true' : 'false' )
|
||||
. ' url-left-right=' . ( $swapLeftRightInURL ? 'true' : 'false' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTransformBrokenCases
|
||||
* @group Broken
|
||||
|
|
|
|||
|
|
@ -112,8 +112,7 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
|
|||
public function testUnset( GenericArrayObject $list ) {
|
||||
if ( $list->isEmpty() ) {
|
||||
$this->assertTrue( true ); // We cannot test unset if there are no elements
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$offset = $list->getIterator()->key();
|
||||
$count = $list->count();
|
||||
$list->offsetUnset( $offset );
|
||||
|
|
@ -154,7 +153,7 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals( $listSize, $list->count() );
|
||||
|
||||
$this->checkTypeChecks( function( GenericArrayObject $list, $element ) {
|
||||
$this->checkTypeChecks( function ( GenericArrayObject $list, $element ) {
|
||||
$list->append( $element );
|
||||
} );
|
||||
}
|
||||
|
|
@ -173,11 +172,10 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
|
|||
foreach ( array( 42, 'foo', array(), new stdClass(), 4.2 ) as $element ) {
|
||||
$validValid = $element instanceof $elementClass;
|
||||
|
||||
try{
|
||||
try {
|
||||
call_user_func( $function, $list, $element );
|
||||
$valid = true;
|
||||
}
|
||||
catch ( InvalidArgumentException $exception ) {
|
||||
} catch ( InvalidArgumentException $exception ) {
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
|
|
@ -236,7 +234,7 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals( count( $elements ), $list->count() );
|
||||
|
||||
$this->checkTypeChecks( function( GenericArrayObject $list, $element ) {
|
||||
$this->checkTypeChecks( function ( GenericArrayObject $list, $element ) {
|
||||
$list->offsetSet( mt_rand(), $element );
|
||||
} );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
class IEUrlExtensionTest extends MediaWikiTestCase {
|
||||
function testSimple() {
|
||||
$this->assertEquals(
|
||||
$this->assertEquals(
|
||||
'y',
|
||||
IEUrlExtension::findIE6Extension( 'x.y' ),
|
||||
'Simple extension'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
|
|||
* At some point there was a bug that caused this comment to be ended at '* /',
|
||||
* causing /M... to be left as the beginning of a regex.
|
||||
*/
|
||||
array( "/**\n * Foo\n * {\n * 'bar' : {\n * //Multiple rules with configurable operators\n * 'baz' : false\n * }\n */", ""),
|
||||
array( "/**\n * Foo\n * {\n * 'bar' : {\n * //Multiple rules with configurable operators\n * 'baz' : false\n * }\n */", "" ),
|
||||
|
||||
/**
|
||||
* ' Foo \' bar \
|
||||
|
|
@ -80,7 +80,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
|
|||
array( "switch(x){case y?z:{}/ x/g:{}/ x/g;}", "switch(x){case y?z:{}/x/g:{}/ x/g;}" ),
|
||||
array( "function x(){}/ x/g", "function x(){}/ x/g" ),
|
||||
array( "+function x(){}/ x/g", "+function x(){}/x/g" ),
|
||||
|
||||
|
||||
// Multiline quoted string
|
||||
array( "var foo=\"\\\nblah\\\n\";", "var foo=\"\\\nblah\\\n\";" ),
|
||||
|
||||
|
|
@ -96,16 +96,16 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
|
|||
// Division vs. regex nastiness
|
||||
array( "alert( (10+10) / '/'.charCodeAt( 0 ) + '//' );", "alert((10+10)/'/'.charCodeAt(0)+'//');" ),
|
||||
array( "if(1)/a /g.exec('Pa ss');", "if(1)/a /g.exec('Pa ss');" ),
|
||||
|
||||
|
||||
// newline insertion after 1000 chars: break after the "++", not before
|
||||
array( str_repeat( ';', 996 ) . "if(x++);", str_repeat( ';', 996 ) . "if(x++\n);" ),
|
||||
|
||||
// Unicode letter characters should pass through ok in identifiers (bug 31187)
|
||||
array( "var KaŝSkatolVal = {}", 'var KaŝSkatolVal={}'),
|
||||
array( "var KaŝSkatolVal = {}", 'var KaŝSkatolVal={}' ),
|
||||
|
||||
// Per spec unicode char escape values should work in identifiers,
|
||||
// as long as it's a valid char. In future it might get normalized.
|
||||
array( "var Ka\\u015dSkatolVal = {}", 'var Ka\\u015dSkatolVal={}'),
|
||||
array( "var Ka\\u015dSkatolVal = {}", 'var Ka\\u015dSkatolVal={}' ),
|
||||
|
||||
// Some structures that might look invalid at first sight
|
||||
array( "var a = 5.;", "var a=5.;" ),
|
||||
|
|
@ -137,7 +137,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
|
|||
array(
|
||||
// This one gets interpreted all together by the prior code;
|
||||
// no break at the 'E' happens.
|
||||
'1.23456789E55',
|
||||
'1.23456789E55',
|
||||
),
|
||||
array(
|
||||
// This one breaks under the bad code; splits between 'E' and '+'
|
||||
|
|
@ -165,6 +165,6 @@ class JavaScriptMinifierTest extends MediaWikiTestCase {
|
|||
|
||||
$minified = JavaScriptMinifier::minify( $input );
|
||||
|
||||
$this->assertEquals( $expected, $minified, "Line breaks must not occur in middle of exponent");
|
||||
$this->assertEquals( $expected, $minified, "Line breaks must not occur in middle of exponent" );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class LogFormatterTest extends MediaWikiLangTestCase {
|
|||
'wgLogActionsHandlers' => array( 'phpunit/test' => 'LogFormatter',
|
||||
'phpunit/param' => 'LogFormatter' ),
|
||||
'wgUser' => User::newFromName( 'Testuser' ),
|
||||
'wgExtensionMessagesFiles' => array( 'LogTests' => __DIR__.'/LogTests.i18n.php' ),
|
||||
'wgExtensionMessagesFiles' => array( 'LogTests' => __DIR__ . '/LogTests.i18n.php' ),
|
||||
) );
|
||||
|
||||
$wgLang->getLocalisationCache()->recache( $wgLang->getCode() );
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
$messages = array();
|
||||
|
||||
$messages['en'] = array(
|
||||
'log-name-phpunit' => 'PHPUnit-log',
|
||||
'log-name-phpunit' => 'PHPUnit-log',
|
||||
'log-description-phpunit' => 'Log for PHPUnit-tests',
|
||||
'logentry-phpunit-test' => '$1 {{GENDER:$2|tests}} with page $3',
|
||||
'logentry-phpunit-param' => '$4',
|
||||
'logentry-phpunit-test' => '$1 {{GENDER:$2|tests}} with page $3',
|
||||
'logentry-phpunit-param' => '$4',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
|
|||
|
||||
$expected = array(
|
||||
'x-default' => 'right(iptc)',
|
||||
'en' => 'right translation',
|
||||
'_type' => 'lang'
|
||||
'en' => 'right translation',
|
||||
'_type' => 'lang'
|
||||
);
|
||||
|
||||
|
||||
$this->assertArrayHasKey( 'ImageDescription', $meta,
|
||||
'Did not extract any ImageDescription info?!' );
|
||||
|
||||
|
|
@ -122,25 +122,25 @@ class BitmapMetadataHandlerTest extends MediaWikiTestCase {
|
|||
}
|
||||
$handler = new BitmapMetadataHandler();
|
||||
$result = $handler->png( $this->filePath . 'xmp.png' );
|
||||
$expected = array (
|
||||
$expected = array(
|
||||
'frameCount' => 0,
|
||||
'loopCount' => 1,
|
||||
'duration' => 0,
|
||||
'bitDepth' => 1,
|
||||
'colorType' => 'index-coloured',
|
||||
'metadata' => array (
|
||||
'metadata' => array(
|
||||
'SerialNumber' => '123456789',
|
||||
'_MW_PNG_VERSION' => 1,
|
||||
),
|
||||
);
|
||||
$this->assertEquals( $expected, $result );
|
||||
$this->assertEquals( $expected, $result );
|
||||
}
|
||||
|
||||
public function testPNGNative() {
|
||||
$handler = new BitmapMetadataHandler();
|
||||
$result = $handler->png( $this->filePath . 'Png-native-test.png' );
|
||||
$expected = 'http://example.com/url';
|
||||
$this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] );
|
||||
$this->assertEquals( $expected, $result['metadata']['Identifier']['x-default'] );
|
||||
}
|
||||
|
||||
public function testTiffByteOrder() {
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ class BitmapScalingTest extends MediaWikiTestCase {
|
|||
$this->assertTrue( $valid );
|
||||
$this->assertEquals( $expectedParams, $params, $msg );
|
||||
}
|
||||
|
||||
|
||||
function provideNormaliseParams() {
|
||||
return array(
|
||||
/* Regular resize operations */
|
||||
/* Regular resize operations */
|
||||
array(
|
||||
array( 1024, 768 ),
|
||||
array(
|
||||
'width' => 512, 'height' => 384,
|
||||
array(
|
||||
'width' => 512, 'height' => 384,
|
||||
'physicalWidth' => 512, 'physicalHeight' => 384,
|
||||
'page' => 1,
|
||||
),
|
||||
|
|
@ -37,53 +37,53 @@ class BitmapScalingTest extends MediaWikiTestCase {
|
|||
),
|
||||
array(
|
||||
array( 1024, 768 ),
|
||||
array(
|
||||
'width' => 512, 'height' => 384,
|
||||
array(
|
||||
'width' => 512, 'height' => 384,
|
||||
'physicalWidth' => 512, 'physicalHeight' => 384,
|
||||
'page' => 1,
|
||||
'page' => 1,
|
||||
),
|
||||
array( 'width' => 512, 'height' => 768 ),
|
||||
'Resizing with height set too high',
|
||||
),
|
||||
array(
|
||||
array( 1024, 768 ),
|
||||
array(
|
||||
'width' => 512, 'height' => 384,
|
||||
array(
|
||||
'width' => 512, 'height' => 384,
|
||||
'physicalWidth' => 512, 'physicalHeight' => 384,
|
||||
'page' => 1,
|
||||
'page' => 1,
|
||||
),
|
||||
array( 'width' => 1024, 'height' => 384 ),
|
||||
'Resizing with height set',
|
||||
),
|
||||
|
||||
|
||||
/* Very tall images */
|
||||
array(
|
||||
array( 1000, 100 ),
|
||||
array(
|
||||
array(
|
||||
'width' => 5, 'height' => 1,
|
||||
'physicalWidth' => 5, 'physicalHeight' => 1,
|
||||
'page' => 1,
|
||||
'page' => 1,
|
||||
),
|
||||
array( 'width' => 5 ),
|
||||
'Very wide image',
|
||||
),
|
||||
|
||||
|
||||
array(
|
||||
array( 100, 1000 ),
|
||||
array(
|
||||
array(
|
||||
'width' => 1, 'height' => 10,
|
||||
'physicalWidth' => 1, 'physicalHeight' => 10,
|
||||
'page' => 1,
|
||||
'page' => 1,
|
||||
),
|
||||
array( 'width' => 1 ),
|
||||
'Very high image',
|
||||
),
|
||||
array(
|
||||
array( 100, 1000 ),
|
||||
array(
|
||||
array(
|
||||
'width' => 1, 'height' => 5,
|
||||
'physicalWidth' => 1, 'physicalHeight' => 10,
|
||||
'page' => 1,
|
||||
'page' => 1,
|
||||
),
|
||||
array( 'width' => 10, 'height' => 5 ),
|
||||
'Very high image with height set',
|
||||
|
|
@ -91,10 +91,10 @@ class BitmapScalingTest extends MediaWikiTestCase {
|
|||
/* Max image area */
|
||||
array(
|
||||
array( 4000, 4000 ),
|
||||
array(
|
||||
array(
|
||||
'width' => 5000, 'height' => 5000,
|
||||
'physicalWidth' => 4000, 'physicalHeight' => 4000,
|
||||
'page' => 1,
|
||||
'page' => 1,
|
||||
),
|
||||
array( 'width' => 5000 ),
|
||||
'Bigger than max image size but doesn\'t need scaling',
|
||||
|
|
@ -106,7 +106,7 @@ class BitmapScalingTest extends MediaWikiTestCase {
|
|||
$file = new FakeDimensionFile( array( 4000, 4000 ) );
|
||||
$handler = new BitmapHandler;
|
||||
$params = array( 'width' => '3700' ); // Still bigger than max size.
|
||||
$this->assertEquals( 'TransformParameterError',
|
||||
$this->assertEquals( 'TransformParameterError',
|
||||
get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
|
||||
}
|
||||
|
||||
|
|
@ -115,10 +115,10 @@ class BitmapScalingTest extends MediaWikiTestCase {
|
|||
$file->mustRender = true;
|
||||
$handler = new BitmapHandler;
|
||||
$params = array( 'width' => '5000' ); // Still bigger than max size.
|
||||
$this->assertEquals( 'TransformParameterError',
|
||||
$this->assertEquals( 'TransformParameterError',
|
||||
get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
|
||||
}
|
||||
|
||||
|
||||
function testImageArea() {
|
||||
$file = new FakeDimensionFile( array( 7, 9 ) );
|
||||
$handler = new BitmapHandler;
|
||||
|
|
@ -130,20 +130,24 @@ class FakeDimensionFile extends File {
|
|||
public $mustRender = false;
|
||||
|
||||
public function __construct( $dimensions ) {
|
||||
parent::__construct( Title::makeTitle( NS_FILE, 'Test' ),
|
||||
parent::__construct( Title::makeTitle( NS_FILE, 'Test' ),
|
||||
new NullRepo( null ) );
|
||||
|
||||
|
||||
$this->dimensions = $dimensions;
|
||||
}
|
||||
|
||||
public function getWidth( $page = 1 ) {
|
||||
return $this->dimensions[0];
|
||||
}
|
||||
|
||||
public function getHeight( $page = 1 ) {
|
||||
return $this->dimensions[1];
|
||||
}
|
||||
|
||||
public function mustRender() {
|
||||
return $this->mustRender;
|
||||
}
|
||||
|
||||
public function getPath() {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ class ExifBitmapTest extends MediaWikiTestCase {
|
|||
|
||||
function testConvertMetadataLatest() {
|
||||
$metadata = array(
|
||||
'foo' => array( 'First', 'Second', '_type' => 'ol' ),
|
||||
'MEDIAWIKI_EXIF_VERSION' => 2
|
||||
);
|
||||
'foo' => array( 'First', 'Second', '_type' => 'ol' ),
|
||||
'MEDIAWIKI_EXIF_VERSION' => 2
|
||||
);
|
||||
$res = $this->handler->convertMetadataVersion( $metadata, 2 );
|
||||
$this->assertEquals( $metadata, $res );
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ class ExifBitmapTest extends MediaWikiTestCase {
|
|||
|
||||
function testConvertMetadataSoftware() {
|
||||
$metadata = array(
|
||||
'Software' => array( array('GIMP', '1.1' ) ),
|
||||
'Software' => array( array( 'GIMP', '1.1' ) ),
|
||||
'MEDIAWIKI_EXIF_VERSION' => 2,
|
||||
);
|
||||
$expected = array(
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
$tmpDir = $this->getNewTempDirectory();
|
||||
|
||||
$this->repo = new FSRepo( array(
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'backend' => new FSFileBackend( array(
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'backend' => new FSFileBackend( array(
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'containerPaths' => array( 'temp-thumb' => $tmpDir, 'data' => $filePath )
|
||||
) )
|
||||
) );
|
||||
|
|
@ -63,8 +63,8 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
if ( !BitmapHandler::canRotate() ) {
|
||||
$this->markTestSkipped( "This test needs a rasterizer that can auto-rotate." );
|
||||
}
|
||||
foreach( $thumbs as $size => $out ) {
|
||||
if( preg_match('/^(\d+)px$/', $size, $matches ) ) {
|
||||
foreach ( $thumbs as $size => $out ) {
|
||||
if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) {
|
||||
$params = array(
|
||||
'width' => $matches[1],
|
||||
);
|
||||
|
|
@ -74,7 +74,7 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
'height' => $matches[2]
|
||||
);
|
||||
} else {
|
||||
throw new MWException('bogus test data format ' . $size);
|
||||
throw new MWException( 'bogus test data format ' . $size );
|
||||
}
|
||||
|
||||
$file = $this->dataFile( $name, $type );
|
||||
|
|
@ -84,13 +84,13 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( $out[1], $thumb->getHeight(), "$name: thumb reported height check for $size" );
|
||||
|
||||
$gis = getimagesize( $thumb->getLocalCopyPath() );
|
||||
if ($out[0] > $info['width']) {
|
||||
if ( $out[0] > $info['width'] ) {
|
||||
// Physical image won't be scaled bigger than the original.
|
||||
$this->assertEquals( $info['width'], $gis[0], "$name: thumb actual width check for $size");
|
||||
$this->assertEquals( $info['height'], $gis[1], "$name: thumb actual height check for $size");
|
||||
$this->assertEquals( $info['width'], $gis[0], "$name: thumb actual width check for $size" );
|
||||
$this->assertEquals( $info['height'], $gis[1], "$name: thumb actual height check for $size" );
|
||||
} else {
|
||||
$this->assertEquals( $out[0], $gis[0], "$name: thumb actual width check for $size");
|
||||
$this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size");
|
||||
$this->assertEquals( $out[0], $gis[0], "$name: thumb actual width check for $size" );
|
||||
$this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -157,8 +157,8 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
global $wgEnableAutoRotation;
|
||||
$wgEnableAutoRotation = false;
|
||||
|
||||
foreach( $thumbs as $size => $out ) {
|
||||
if( preg_match('/^(\d+)px$/', $size, $matches ) ) {
|
||||
foreach ( $thumbs as $size => $out ) {
|
||||
if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) {
|
||||
$params = array(
|
||||
'width' => $matches[1],
|
||||
);
|
||||
|
|
@ -168,7 +168,7 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
'height' => $matches[2]
|
||||
);
|
||||
} else {
|
||||
throw new MWException('bogus test data format ' . $size);
|
||||
throw new MWException( 'bogus test data format ' . $size );
|
||||
}
|
||||
|
||||
$file = $this->dataFile( $name, $type );
|
||||
|
|
@ -178,13 +178,13 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( $out[1], $thumb->getHeight(), "$name: thumb reported height check for $size" );
|
||||
|
||||
$gis = getimagesize( $thumb->getLocalCopyPath() );
|
||||
if ($out[0] > $info['width']) {
|
||||
if ( $out[0] > $info['width'] ) {
|
||||
// Physical image won't be scaled bigger than the original.
|
||||
$this->assertEquals( $info['width'], $gis[0], "$name: thumb actual width check for $size");
|
||||
$this->assertEquals( $info['height'], $gis[1], "$name: thumb actual height check for $size");
|
||||
$this->assertEquals( $info['width'], $gis[0], "$name: thumb actual width check for $size" );
|
||||
$this->assertEquals( $info['height'], $gis[1], "$name: thumb actual height check for $size" );
|
||||
} else {
|
||||
$this->assertEquals( $out[0], $gis[0], "$name: thumb actual width check for $size");
|
||||
$this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size");
|
||||
$this->assertEquals( $out[0], $gis[0], "$name: thumb actual width check for $size" );
|
||||
$this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size" );
|
||||
}
|
||||
}
|
||||
$wgEnableAutoRotation = true;
|
||||
|
|
@ -232,9 +232,9 @@ class ExifRotationTest extends MediaWikiTestCase {
|
|||
*/
|
||||
function testBitmapExtractPreRotationDimensions( $rotation, $expected ) {
|
||||
$result = $this->handler->extractPreRotationDimensions( array(
|
||||
'physicalWidth' => self::TEST_WIDTH,
|
||||
'physicalHeight' => self::TEST_HEIGHT,
|
||||
), $rotation );
|
||||
'physicalWidth' => self::TEST_WIDTH,
|
||||
'physicalHeight' => self::TEST_HEIGHT,
|
||||
), $rotation );
|
||||
$this->assertEquals( $expected, $result );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class ExifTest extends MediaWikiTestCase {
|
|||
|
||||
public function testGPSExtraction() {
|
||||
$filename = $this->mediaPath . 'exif-gps.jpg';
|
||||
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
|
||||
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
|
||||
$exif = new Exif( $filename, $seg['byteOrder'] );
|
||||
$data = $exif->getFilteredData();
|
||||
$expected = array(
|
||||
|
|
@ -30,7 +30,7 @@ class ExifTest extends MediaWikiTestCase {
|
|||
|
||||
public function testUnicodeUserComment() {
|
||||
$filename = $this->mediaPath . 'exif-user-comment.jpg';
|
||||
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
|
||||
$seg = JpegMetadataExtractor::segmentSplitter( $filename );
|
||||
$exif = new Exif( $filename, $seg['byteOrder'] );
|
||||
$data = $exif->getFilteredData();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ class FormatMetadataTest extends MediaWikiTestCase {
|
|||
if ( !wfDl( 'exif' ) ) {
|
||||
$this->markTestSkipped( "This test needs the exif extension." );
|
||||
}
|
||||
$filePath = __DIR__ . '/../../data/media';
|
||||
$filePath = __DIR__ . '/../../data/media';
|
||||
$this->backend = new FSFileBackend( array(
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'containerPaths' => array( 'data' => $filePath )
|
||||
) );
|
||||
$this->repo = new FSRepo( array(
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'backend' => $this->backend
|
||||
) );
|
||||
|
||||
|
|
@ -24,11 +24,11 @@ class FormatMetadataTest extends MediaWikiTestCase {
|
|||
|
||||
public function testInvalidDate() {
|
||||
$file = $this->dataFile( 'broken_exif_date.jpg', 'image/jpeg' );
|
||||
|
||||
|
||||
// Throws an error if bug hit
|
||||
$meta = $file->formatMetadata();
|
||||
$this->assertNotEquals( false, $meta, 'Valid metadata extracted' );
|
||||
|
||||
|
||||
// Find date exif entry
|
||||
$this->assertArrayHasKey( 'visible', $meta );
|
||||
$dateIndex = null;
|
||||
|
|
@ -38,7 +38,7 @@ class FormatMetadataTest extends MediaWikiTestCase {
|
|||
}
|
||||
}
|
||||
$this->assertNotNull( $dateIndex, 'Date entry exists in metadata' );
|
||||
$this->assertEquals( '0000:01:00 00:02:27',
|
||||
$this->assertEquals( '0000:01:00 00:02:27',
|
||||
$meta['visible'][$dateIndex]['value'],
|
||||
'File with invalid date metadata (bug 29471)' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class GIFMetadataExtractorTest extends MediaWikiTestCase {
|
|||
|
||||
$this->mediaPath = __DIR__ . '/../../data/media/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in a file, and see if the metadata coming out is as expected.
|
||||
* @param $filename String
|
||||
|
|
@ -16,6 +17,7 @@ class GIFMetadataExtractorTest extends MediaWikiTestCase {
|
|||
$actual = GIFMetadataExtractor::getMetadata( $this->mediaPath . $filename );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideGetMetadata() {
|
||||
|
||||
$xmpNugget = <<<EOF
|
||||
|
|
@ -68,29 +70,35 @@ EOF;
|
|||
$xmpNugget = str_replace( "\r", '', $xmpNugget ); // Windows compat
|
||||
|
||||
return array(
|
||||
array( 'nonanimated.gif', array(
|
||||
'comment' => array( 'GIF test file ⁕ Created with GIMP' ),
|
||||
'duration' => 0.1,
|
||||
'frameCount' => 1,
|
||||
'looped' => false,
|
||||
'xmp' => '',
|
||||
array(
|
||||
'nonanimated.gif',
|
||||
array(
|
||||
'comment' => array( 'GIF test file ⁕ Created with GIMP' ),
|
||||
'duration' => 0.1,
|
||||
'frameCount' => 1,
|
||||
'looped' => false,
|
||||
'xmp' => '',
|
||||
)
|
||||
),
|
||||
array( 'animated.gif', array(
|
||||
'comment' => array( 'GIF test file . Created with GIMP' ),
|
||||
'duration' => 2.4,
|
||||
'frameCount' => 4,
|
||||
'looped' => true,
|
||||
'xmp' => '',
|
||||
array(
|
||||
'animated.gif',
|
||||
array(
|
||||
'comment' => array( 'GIF test file . Created with GIMP' ),
|
||||
'duration' => 2.4,
|
||||
'frameCount' => 4,
|
||||
'looped' => true,
|
||||
'xmp' => '',
|
||||
)
|
||||
),
|
||||
|
||||
array( 'animated-xmp.gif', array(
|
||||
'xmp' => $xmpNugget,
|
||||
'duration' => 2.4,
|
||||
'frameCount' => 4,
|
||||
'looped' => true,
|
||||
'comment' => array( 'GIƒ·test·file' ),
|
||||
array(
|
||||
'animated-xmp.gif',
|
||||
array(
|
||||
'xmp' => $xmpNugget,
|
||||
'duration' => 2.4,
|
||||
'frameCount' => 4,
|
||||
'looped' => true,
|
||||
'comment' => array( 'GIƒ·test·file' ),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ class GIFHandlerTest extends MediaWikiTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->filePath = __DIR__ . '/../../data/media';
|
||||
$this->filePath = __DIR__ . '/../../data/media';
|
||||
$this->backend = new FSFileBackend( array(
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'containerPaths' => array( 'data' => $this->filePath )
|
||||
) );
|
||||
$this->repo = new FSRepo( array(
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'backend' => $this->backend
|
||||
) );
|
||||
$this->handler = new GIFHandler();
|
||||
|
|
@ -33,6 +33,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
|
|||
$actual = $this->handler->isAnimatedImage( $file );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideIsAnimated() {
|
||||
return array(
|
||||
array( 'animated.gif', true ),
|
||||
|
|
@ -50,6 +51,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
|
|||
$actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideGetImageArea() {
|
||||
return array(
|
||||
array( 'animated.gif', 5400 ),
|
||||
|
|
@ -66,6 +68,7 @@ class GIFHandlerTest extends MediaWikiTestCase {
|
|||
$actual = $this->handler->isMetadataValid( null, $metadata );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideIsMetadataValid() {
|
||||
return array(
|
||||
array( GIFHandler::BROKEN_FILE, GIFHandler::METADATA_GOOD ),
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class IPTCTest extends MediaWikiTestCase {
|
|||
$res = IPTC::Parse( $iptcData );
|
||||
$this->assertEquals( array( '¼' ), $res['Keywords'] );
|
||||
}
|
||||
|
||||
/* This one contains a sequence that's valid iso 8859-1 but not valid utf8 */
|
||||
/* \xC3 = Ã, \xB8 = ¸ */
|
||||
public function testIPTCParseNoCharset88591b() {
|
||||
|
|
@ -21,6 +22,7 @@ class IPTCTest extends MediaWikiTestCase {
|
|||
$res = IPTC::Parse( $iptcData );
|
||||
$this->assertEquals( array( 'ÃÃø' ), $res['Keywords'] );
|
||||
}
|
||||
|
||||
/* Same as testIPTCParseNoCharset88591b, but forcing the charset to utf-8.
|
||||
* What should happen is the first "\xC3\xC3" should be dropped as invalid,
|
||||
* leaving \xC3\xB8, which is ø
|
||||
|
|
@ -31,11 +33,13 @@ class IPTCTest extends MediaWikiTestCase {
|
|||
$res = IPTC::Parse( $iptcData );
|
||||
$this->assertEquals( array( 'ø' ), $res['Keywords'] );
|
||||
}
|
||||
|
||||
public function testIPTCParseNoCharsetUTF8() {
|
||||
$iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x07\x1c\x02\x19\x00\x02¼";
|
||||
$res = IPTC::Parse( $iptcData );
|
||||
$this->assertEquals( array( '¼' ), $res['Keywords'] );
|
||||
}
|
||||
|
||||
// Testing something that has 2 values for keyword
|
||||
public function testIPTCParseMulti() {
|
||||
$iptcData = /* identifier */ "Photoshop 3.0\08BIM\4\4"
|
||||
|
|
@ -45,6 +49,7 @@ class IPTCTest extends MediaWikiTestCase {
|
|||
$res = IPTC::Parse( $iptcData );
|
||||
$this->assertEquals( array( '¼', '¼½' ), $res['Keywords'] );
|
||||
}
|
||||
|
||||
public function testIPTCParseUTF8() {
|
||||
// This has the magic "\x1c\x01\x5A\x00\x03\x1B\x25\x47" which marks content as UTF8.
|
||||
$iptcData = "Photoshop 3.0\08BIM\4\4\0\0\0\0\0\x0F\x1c\x02\x19\x00\x02¼\x1c\x01\x5A\x00\x03\x1B\x25\x47";
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
|
|||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . $file );
|
||||
$this->assertEquals( array( 'UTF-8 JPEG Comment — ¼' ), $res['COM'] );
|
||||
}
|
||||
|
||||
public static function provideUtf8Comment() {
|
||||
return array(
|
||||
array( 'jpeg-comment-utf.jpg' ),
|
||||
|
|
@ -33,11 +34,13 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
|
|||
array( 'jpeg-padding-odd.jpg' ),
|
||||
);
|
||||
}
|
||||
|
||||
/** The file is iso-8859-1, but it should get auto converted */
|
||||
public function testIso88591Comment() {
|
||||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-iso8859-1.jpg' );
|
||||
$this->assertEquals( array( 'ISO-8859-1 JPEG Comment - ¼' ), $res['COM'] );
|
||||
}
|
||||
|
||||
/** Comment values that are non-textual (random binary junk) should not be shown.
|
||||
* The example test file has a comment with a 0x5 byte in it which is a control character
|
||||
* and considered binary junk for our purposes.
|
||||
|
|
@ -46,6 +49,7 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
|
|||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-binary.jpg' );
|
||||
$this->assertEmpty( $res['COM'] );
|
||||
}
|
||||
|
||||
/* Very rarely a file can have multiple comments.
|
||||
* Order of comments is based on order inside the file.
|
||||
*/
|
||||
|
|
@ -53,16 +57,19 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
|
|||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-comment-multiple.jpg' );
|
||||
$this->assertEquals( array( 'foo', 'bar' ), $res['COM'] );
|
||||
}
|
||||
|
||||
public function testXMPExtraction() {
|
||||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' );
|
||||
$expected = file_get_contents( $this->filePath . 'jpeg-xmp-psir.xmp' );
|
||||
$this->assertEquals( $expected, $res['XMP'] );
|
||||
}
|
||||
|
||||
public function testPSIRExtraction() {
|
||||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-psir.jpg' );
|
||||
$expected = '50686f746f73686f7020332e30003842494d04040000000000181c02190004746573741c02190003666f6f1c020000020004';
|
||||
$this->assertEquals( $expected, bin2hex( $res['PSIR'][0] ) );
|
||||
}
|
||||
|
||||
public function testXMPExtractionAltAppId() {
|
||||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-xmp-alt.jpg' );
|
||||
$expected = file_get_contents( $this->filePath . 'jpeg-xmp-psir.xmp' );
|
||||
|
|
@ -76,18 +83,21 @@ class JpegMetadataExtractorTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals( 'iptc-no-hash', $res );
|
||||
}
|
||||
|
||||
public function testIPTCHashComparisionBadHash() {
|
||||
$segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-iptc-bad-hash.jpg' );
|
||||
$res = JpegMetadataExtractor::doPSIR( $segments['PSIR'][0] );
|
||||
|
||||
$this->assertEquals( 'iptc-bad-hash', $res );
|
||||
}
|
||||
|
||||
public function testIPTCHashComparisionGoodHash() {
|
||||
$segments = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'jpeg-iptc-good-hash.jpg' );
|
||||
$res = JpegMetadataExtractor::doPSIR( $segments['PSIR'][0] );
|
||||
|
||||
$this->assertEquals( 'iptc-good-hash', $res );
|
||||
}
|
||||
|
||||
public function testExifByteOrder() {
|
||||
$res = JpegMetadataExtractor::segmentSplitter( $this->filePath . 'exif-user-comment.jpg' );
|
||||
$expected = 'BE';
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
parent::setUp();
|
||||
$this->filePath = __DIR__ . '/../../data/media/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests zTXt tag (compressed textual metadata)
|
||||
* Tests zTXt tag (compressed textual metadata)
|
||||
*/
|
||||
function testPngNativetZtxt() {
|
||||
$this->checkPHPExtension( 'zlib' );
|
||||
|
|
@ -64,7 +65,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
* Test extraction of pHYs tags, which can tell what the
|
||||
* actual resolution of the image is (aka in dots per meter).
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
function testPngPhysTag () {
|
||||
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
|
||||
'Png-native-test.png' );
|
||||
|
|
@ -76,7 +77,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
$this->assertEquals( '2835/100', $meta['YResolution'] );
|
||||
$this->assertEquals( 3, $meta['ResolutionUnit'] ); // 3 = cm
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Given a normal static PNG, check the animation metadata returned.
|
||||
|
|
@ -110,6 +111,7 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals( 8, $meta['bitDepth'] );
|
||||
}
|
||||
|
||||
function testPngBitDepth1() {
|
||||
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
|
||||
'1bit-png.png' );
|
||||
|
|
@ -123,21 +125,25 @@ class PNGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals( 'index-coloured', $meta['colorType'] );
|
||||
}
|
||||
|
||||
function testPngRgbColour() {
|
||||
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
|
||||
'rgb-png.png' );
|
||||
$this->assertEquals( 'truecolour-alpha', $meta['colorType'] );
|
||||
}
|
||||
|
||||
function testPngRgbNoAlphaColour() {
|
||||
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
|
||||
'rgb-na-png.png' );
|
||||
$this->assertEquals( 'truecolour', $meta['colorType'] );
|
||||
}
|
||||
|
||||
function testPngGreyscaleColour() {
|
||||
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
|
||||
'greyscale-png.png' );
|
||||
$this->assertEquals( 'greyscale-alpha', $meta['colorType'] );
|
||||
}
|
||||
|
||||
function testPngGreyscaleNoAlphaColour() {
|
||||
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
|
||||
'greyscale-na-png.png' );
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ class PNGHandlerTest extends MediaWikiTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->filePath = __DIR__ . '/../../data/media';
|
||||
$this->filePath = __DIR__ . '/../../data/media';
|
||||
$this->backend = new FSFileBackend( array(
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'name' => 'localtesting',
|
||||
'lockManager' => 'nullLockManager',
|
||||
'containerPaths' => array( 'data' => $this->filePath )
|
||||
) );
|
||||
$this->repo = new FSRepo( array(
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'name' => 'temp',
|
||||
'url' => 'http://localhost/thumbtest',
|
||||
'backend' => $this->backend
|
||||
) );
|
||||
$this->handler = new PNGHandler();
|
||||
|
|
@ -22,6 +22,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
|
|||
$res = $this->handler->getMetadata( null, $this->filePath . '/README' );
|
||||
$this->assertEquals( PNGHandler::BROKEN_FILE, $res );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename String basename of the file to check
|
||||
* @param $expected boolean Expected result.
|
||||
|
|
@ -32,6 +33,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
|
|||
$actual = $this->handler->isAnimatedImage( $file );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideIsAnimated() {
|
||||
return array(
|
||||
array( 'Animated_PNG_example_bouncing_beach_ball.png', true ),
|
||||
|
|
@ -45,10 +47,11 @@ class PNGHandlerTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideGetImageArea
|
||||
*/
|
||||
public function testGetImageArea( $filename, $expected ) {
|
||||
$file = $this->dataFile($filename, 'image/png' );
|
||||
$file = $this->dataFile( $filename, 'image/png' );
|
||||
$actual = $this->handler->getImageArea( $file, $file->getWidth(), $file->getHeight() );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideGetImageArea() {
|
||||
return array(
|
||||
array( '1bit-png.png', 2500 ),
|
||||
|
|
@ -67,6 +70,7 @@ class PNGHandlerTest extends MediaWikiTestCase {
|
|||
$actual = $this->handler->isMetadataValid( null, $metadata );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
public static function provideIsMetadataValid() {
|
||||
return array(
|
||||
array( PNGHandler::BROKEN_FILE, PNGHandler::METADATA_GOOD ),
|
||||
|
|
@ -88,10 +92,11 @@ class PNGHandlerTest extends MediaWikiTestCase {
|
|||
// $this->assertEquals( unserialize( $expected ), unserialize( $actual ) );
|
||||
$this->assertEquals( ( $expected ), ( $actual ) );
|
||||
}
|
||||
|
||||
public static function provideGetMetadata() {
|
||||
return array(
|
||||
array( 'rgb-na-png.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:8;s:9:"colorType";s:10:"truecolour";s:8:"metadata";a:1:{s:15:"_MW_PNG_VERSION";i:1;}}' ),
|
||||
array( 'xmp.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:1;s:9:"colorType";s:14:"index-coloured";s:8:"metadata";a:2:{s:12:"SerialNumber";s:9:"123456789";s:15:"_MW_PNG_VERSION";i:1;}}' ),
|
||||
array( 'xmp.png', 'a:6:{s:10:"frameCount";i:0;s:9:"loopCount";i:1;s:8:"duration";d:0;s:8:"bitDepth";i:1;s:9:"colorType";s:14:"index-coloured";s:8:"metadata";a:2:{s:12:"SerialNumber";s:9:"123456789";s:15:"_MW_PNG_VERSION";i:1;}}' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
function testGetMetadata( $infile, $expected ) {
|
||||
$this->assertMetadata( $infile, $expected );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider provideSvgFilesWithXMLMetadata
|
||||
*/
|
||||
function testGetXMLMetadata( $infile, $expected ) {
|
||||
$r = new XMLReader();
|
||||
if( !method_exists( $r, 'readInnerXML' ) ) {
|
||||
if ( !method_exists( $r, 'readInnerXML' ) ) {
|
||||
$this->markTestSkipped( 'XMLReader::readInnerXML() does not exist (libxml >2.6.20 needed).' );
|
||||
return;
|
||||
}
|
||||
|
|
@ -84,8 +84,7 @@ class SVGMetadataExtractorTest extends MediaWikiTestCase {
|
|||
|
||||
public static function provideSvgFilesWithXMLMetadata() {
|
||||
$base = __DIR__ . '/../../data/media';
|
||||
$metadata =
|
||||
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
$metadata = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<ns4:Work xmlns:ns4="http://creativecommons.org/ns#" rdf:about="">
|
||||
<ns5:format xmlns:ns5="http://purl.org/dc/elements/1.1/">image/svg+xml</ns5:format>
|
||||
<ns5:type xmlns:ns5="http://purl.org/dc/elements/1.1/" rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class XMPTest extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
public static function provideXMPParse() {
|
||||
$xmpPath = __DIR__ . '/../../data/xmp/' ;
|
||||
$xmpPath = __DIR__ . '/../../data/xmp/';
|
||||
$data = array();
|
||||
|
||||
// $xmpFiles format: array of arrays with first arg file base name,
|
||||
|
|
@ -54,8 +54,9 @@ class XMPTest extends MediaWikiTestCase {
|
|||
array( 'utf32LE', 'UTF-32LE encoding' ),
|
||||
array( 'xmpExt', 'Extended XMP missing second part' ),
|
||||
array( 'gps', 'Handling of exif GPS parameters in XMP' ),
|
||||
);
|
||||
foreach( $xmpFiles as $file ) {
|
||||
);
|
||||
|
||||
foreach ( $xmpFiles as $file ) {
|
||||
$xmp = file_get_contents( $xmpPath . $file[0] . '.xmp' );
|
||||
// I'm not sure if this is the best way to handle getting the
|
||||
// result array, but it seems kind of big to put directly in the test
|
||||
|
|
@ -88,8 +89,8 @@ class XMPTest extends MediaWikiTestCase {
|
|||
$reader->parseExtended( $extendedPacket );
|
||||
$actual = $reader->getResults();
|
||||
|
||||
$expected = array( 'xmp-exif' =>
|
||||
array(
|
||||
$expected = array(
|
||||
'xmp-exif' => array(
|
||||
'DigitalZoomRatio' => '0/10',
|
||||
'Flash' => 9,
|
||||
'FNumber' => '2/10',
|
||||
|
|
@ -118,8 +119,8 @@ class XMPTest extends MediaWikiTestCase {
|
|||
$reader->parseExtended( $extendedPacket );
|
||||
$actual = $reader->getResults();
|
||||
|
||||
$expected = array( 'xmp-exif' =>
|
||||
array(
|
||||
$expected = array(
|
||||
'xmp-exif' => array(
|
||||
'DigitalZoomRatio' => '0/10',
|
||||
'Flash' => 9,
|
||||
)
|
||||
|
|
@ -127,6 +128,7 @@ class XMPTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* Have a high offset to simulate a missing packet,
|
||||
* which should cause it to ignore the ExtendedXMP packet.
|
||||
|
|
@ -146,8 +148,8 @@ class XMPTest extends MediaWikiTestCase {
|
|||
$reader->parseExtended( $extendedPacket );
|
||||
$actual = $reader->getResults();
|
||||
|
||||
$expected = array( 'xmp-exif' =>
|
||||
array(
|
||||
$expected = array(
|
||||
'xmp-exif' => array(
|
||||
'DigitalZoomRatio' => '0/10',
|
||||
'Flash' => 9,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue