summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/media/ExifRotationTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/media/ExifRotationTest.php')
-rw-r--r--tests/phpunit/includes/media/ExifRotationTest.php59
1 files changed, 42 insertions, 17 deletions
diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php
index 639091d0..25149a05 100644
--- a/tests/phpunit/includes/media/ExifRotationTest.php
+++ b/tests/phpunit/includes/media/ExifRotationTest.php
@@ -5,15 +5,26 @@
*/
class ExifRotationTest extends MediaWikiTestCase {
+ /** track directories creations. Content will be deleted. */
+ private $createdDirs = array();
+
function setUp() {
parent::setUp();
- $this->filePath = dirname( __FILE__ ) . '/../../data/media/';
$this->handler = new BitmapHandler();
- $this->repo = new FSRepo(array(
- 'name' => 'temp',
- 'directory' => wfTempDir() . '/exif-test-' . time() . '-' . mt_rand(),
- 'url' => 'http://localhost/thumbtest'
- ));
+ $filePath = dirname( __FILE__ ) . '/../../data/media';
+
+ $tmpDir = wfTempDir() . '/exif-test-' . time() . '-' . mt_rand();
+ $this->createdDirs[] = $tmpDir;
+
+ $this->repo = new FSRepo( array(
+ 'name' => 'temp',
+ 'url' => 'http://localhost/thumbtest',
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'localtesting',
+ 'lockManager' => 'nullLockManager',
+ 'containerPaths' => array( 'temp-thumb' => $tmpDir, 'data' => $filePath )
+ ) )
+ ) );
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
}
@@ -25,10 +36,23 @@ class ExifRotationTest extends MediaWikiTestCase {
$this->oldAuto = $wgEnableAutoRotation;
$wgEnableAutoRotation = true;
}
+
public function tearDown() {
global $wgShowEXIF, $wgEnableAutoRotation;
$wgShowEXIF = $this->show;
$wgEnableAutoRotation = $this->oldAuto;
+
+ $this->tearDownFiles();
+ }
+
+ private function tearDownFiles() {
+ foreach( $this->createdDirs as $dir ) {
+ wfRecursiveRemoveDir( $dir );
+ }
+ }
+
+ function __destruct() {
+ $this->tearDownFiles();
}
/**
@@ -39,7 +63,7 @@ class ExifRotationTest extends MediaWikiTestCase {
if ( !BitmapHandler::canRotate() ) {
$this->markTestSkipped( "This test needs a rasterizer that can auto-rotate." );
}
- $file = UnregisteredLocalFile::newFromPath( $this->filePath . $name, $type );
+ $file = $this->dataFile( $name, $type );
$this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" );
$this->assertEquals( $info['height'], $file->getHeight(), "$name: height check" );
}
@@ -66,13 +90,13 @@ class ExifRotationTest extends MediaWikiTestCase {
throw new MWException('bogus test data format ' . $size);
}
- $file = $this->localFile( $name, $type );
- $thumb = $file->transform( $params, File::RENDER_NOW );
+ $file = $this->dataFile( $name, $type );
+ $thumb = $file->transform( $params, File::RENDER_NOW | File::RENDER_FORCE );
$this->assertEquals( $out[0], $thumb->getWidth(), "$name: thumb reported width check for $size" );
$this->assertEquals( $out[1], $thumb->getHeight(), "$name: thumb reported height check for $size" );
- $gis = getimagesize( $thumb->getPath() );
+ $gis = getimagesize( $thumb->getLocalCopyPath() );
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");
@@ -84,8 +108,9 @@ class ExifRotationTest extends MediaWikiTestCase {
}
}
- private function localFile( $name, $type ) {
- return new UnregisteredLocalFile( false, $this->repo, $this->filePath . $name, $type );
+ private function dataFile( $name, $type ) {
+ return new UnregisteredLocalFile( false, $this->repo,
+ "mwstore://localtesting/data/$name", $type );
}
function providerFiles() {
@@ -129,7 +154,7 @@ class ExifRotationTest extends MediaWikiTestCase {
global $wgEnableAutoRotation;
$wgEnableAutoRotation = false;
- $file = UnregisteredLocalFile::newFromPath( $this->filePath . $name, $type );
+ $file = $this->dataFile( $name, $type );
$this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" );
$this->assertEquals( $info['height'], $file->getHeight(), "$name: height check" );
@@ -158,13 +183,13 @@ class ExifRotationTest extends MediaWikiTestCase {
throw new MWException('bogus test data format ' . $size);
}
- $file = $this->localFile( $name, $type );
- $thumb = $file->transform( $params, File::RENDER_NOW );
+ $file = $this->dataFile( $name, $type );
+ $thumb = $file->transform( $params, File::RENDER_NOW | File::RENDER_FORCE );
$this->assertEquals( $out[0], $thumb->getWidth(), "$name: thumb reported width check for $size" );
$this->assertEquals( $out[1], $thumb->getHeight(), "$name: thumb reported height check for $size" );
- $gis = getimagesize( $thumb->getPath() );
+ $gis = getimagesize( $thumb->getLocalCopyPath() );
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");
@@ -242,7 +267,7 @@ class ExifRotationTest extends MediaWikiTestCase {
array(
270,
array( self::TEST_HEIGHT, self::TEST_WIDTH )
- ),
+ ),
);
}
}