*/
class ExifRotationTest extends MediaWikiTestCase {
- /** track directories creations. Content will be deleted. */
- private $createdDirs = array();
-
function setUp() {
parent::setUp();
$this->handler = new BitmapHandler();
$filePath = dirname( __FILE__ ) . '/../../data/media';
- $tmpDir = wfTempDir() . '/exif-test-' . time() . '-' . mt_rand();
- $this->createdDirs[] = $tmpDir;
+ $tmpDir = $this->getNewTempDirectory();
$this->repo = new FSRepo( array(
'name' => 'temp',
$wgShowEXIF = $this->show;
$wgEnableAutoRotation = $this->oldAuto;
- $this->tearDownFiles();
- }
-
- private function tearDownFiles() {
- foreach( $this->createdDirs as $dir ) {
- wfRecursiveRemoveDir( $dir );
- }
- }
-
- function __destruct() {
- $this->tearDownFiles();
+ parent::tearDown();
}
/**
file_put_contents( $fname, $contents ), "# bytes written" );
}
- /**
- * obtains a new temporary file name
- *
- * The obtained filename is enlisted to be removed upon tearDown
- *
- * @returns string: absolute name of the temporary file
- */
- protected function getNewTempFile() {
- $fname = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' );
- $this->tmpfiles[] = $fname;
- return $fname;
- }
-
/**
* Default set up function.
*
if ( $this->exceptionFromAddDBData !== null ) {
throw $this->exceptionFromAddDBData;
}
- $this->tmpfiles = array();
$wgUser = new User();
}
- /**
- * Default tear down function
- *
- * Removes all files that have been allocated via self::getNewTempFile, even if
- * they turn out to be (empty or non-empty) directories now.
- */
- function tearDown() {
- foreach ( $this->tmpfiles as $fname ) {
- if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
- unlink( $fname );
- } elseif ( is_dir( $fname ) ) {
- wfRecursiveRemoveDir( $fname );
- }
- }
- parent::tearDown();
- }
-
-
/**
* Step the current XML reader until node end of given name is found.
*