MINOR Ensuring assets/ folder is created before using it in FileLinkTrackingTest (and using ASSETS_PATH constant instead of hardcoding it)

This commit is contained in:
Ingo Schommer 2011-12-16 17:29:50 +01:00
parent 15e9d08eaa
commit 7a80e6d2ea

View File

@ -10,19 +10,21 @@ class FileLinkTrackingTest extends SapphireTest {
parent::setUp(); parent::setUp();
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$fh = fopen(Director::baseFolder() . '/assets/testscript-test-file.pdf', "w"); if(!file_exists(ASSETS_PATH)) mkdir(ASSETS_PATH);
$fh = fopen(ASSETS_PATH . '/testscript-test-file.pdf', "w");
fwrite($fh, str_repeat('x',1000000)); fwrite($fh, str_repeat('x',1000000));
fclose($fh); fclose($fh);
} }
function tearDown() { function tearDown() {
parent::tearDown(); parent::tearDown();
$testFiles = array( $testFiles = array(
'/assets/testscript-test-file.pdf', '/testscript-test-file.pdf',
'/assets/renamed-test-file.pdf', '/renamed-test-file.pdf',
'/assets/renamed-test-file-second-time.pdf', '/renamed-test-file-second-time.pdf',
); );
foreach($testFiles as $file) { foreach($testFiles as $file) {
if(file_exists(Director::baseFolder().$file)) unlink(Director::baseFolder().$file); if(file_exists(ASSETS_PATH . $file)) unlink(ASSETS_PATH . $file);
} }
} }