Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR Making FileTest->setUp()/tearDown() more resilient against in-t…

…est file/folder renames (from r107271)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112560 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit 9d227ba2e4f686c6754e67c57fe9e82cbe59eb25 1 parent 8b88f4a
Ingo Schommer chillu authored
Showing with 9 additions and 9 deletions.
  1. +9 −9 tests/filesystem/FileTest.php
18 tests/filesystem/FileTest.php
View
@@ -131,10 +131,10 @@ function setUp() {
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 @@ function tearDown() {
$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();
Please sign in to comment.
Something went wrong with that request. Please try again.