mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Making FileTest->setUp()/tearDown() more resilient against in-test file/folder renames
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@107271 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
62dd270fba
commit
8d82c3c7b7
@ -131,10 +131,10 @@ class FileTest extends SapphireTest {
|
||||
if(!file_exists(ASSETS_PATH)) mkdir(ASSETS_PATH);
|
||||
|
||||
/* Create a test folders for each of the fixture references */
|
||||
$fileIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($fileIDs as $fileID) {
|
||||
$file = DataObject::get_by_id('Folder', $fileID);
|
||||
if(!file_exists(BASE_PATH."/$file->Filename")) mkdir(BASE_PATH."/$file->Filename");
|
||||
$folderIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($folderIDs as $folderID) {
|
||||
$folder = DataObject::get_by_id('Folder', $folderID);
|
||||
if(!file_exists(BASE_PATH."/$folder->Filename")) mkdir(BASE_PATH."/$folder->Filename");
|
||||
}
|
||||
|
||||
/* Create a test files for each of the fixture references */
|
||||
@ -152,14 +152,14 @@ class FileTest extends SapphireTest {
|
||||
$fileIDs = $this->allFixtureIDs('File');
|
||||
foreach($fileIDs as $fileID) {
|
||||
$file = DataObject::get_by_id('File', $fileID);
|
||||
if(file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
|
||||
if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
|
||||
}
|
||||
|
||||
/* Remove the test folders that we've crated */
|
||||
$fileIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($fileIDs as $fileID) {
|
||||
$file = DataObject::get_by_id('Folder', $fileID);
|
||||
if(file_exists(BASE_PATH."/$file->Filename")) rmdir(BASE_PATH."/$file->Filename");
|
||||
$folderIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($folderIDs as $folderID) {
|
||||
$folder = DataObject::get_by_id('Folder', $folderID);
|
||||
if($folder && file_exists(BASE_PATH."/$folder->Filename")) rmdir(BASE_PATH."/$folder->Filename");
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user