mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR: Unit test fails if the previous build left temp files behind, so they are removed at the start of the test
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@104050 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
98a299d00c
commit
b36fc700da
@ -209,7 +209,19 @@ class UploadTest extends SapphireTest {
|
|||||||
$this->assertEquals(1, count($u->getErrors()), 'There is a single error of the file extension');
|
$this->assertEquals(1, count($u->getErrors()), 'There is a single error of the file extension');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete files in the default uploads directory that match the name pattern.
|
||||||
|
// @param String $namePattern A regular expression applied to files in the directory. If the name matches
|
||||||
|
// the pattern, it is deleted. Directories, . and .. are excluded.
|
||||||
|
function deleteTestUploadFiles($namePattern) {
|
||||||
|
$tmpFolder = ASSETS_PATH . "/" . Upload::$uploads_folder;
|
||||||
|
$files = scandir($tmpFolder);
|
||||||
|
foreach ($files as $f) {
|
||||||
|
if ($f == "." || $f == ".." || is_dir("$tmpFolder/$f")) continue;
|
||||||
|
if (preg_match($namePattern, $f)) unlink("$tmpFolder/$f");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function testUploadTarGzFileTwiceAppendsNumber() {
|
function testUploadTarGzFileTwiceAppendsNumber() {
|
||||||
// create tmp file
|
// create tmp file
|
||||||
$tmpFileName = 'UploadTest_testUpload.tar.gz';
|
$tmpFileName = 'UploadTest_testUpload.tar.gz';
|
||||||
@ -227,7 +239,10 @@ class UploadTest extends SapphireTest {
|
|||||||
'extension' => 'tar.gz',
|
'extension' => 'tar.gz',
|
||||||
'error' => UPLOAD_ERR_OK,
|
'error' => UPLOAD_ERR_OK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Make sure there are none here, otherwise they get renamed incorrectly for the test.
|
||||||
|
$this->deleteTestUploadFiles("/UploadTesttestUpload.*tar\.gz/");
|
||||||
|
|
||||||
// test upload into default folder
|
// test upload into default folder
|
||||||
$u = new Upload();
|
$u = new Upload();
|
||||||
$u->load($tmpFile);
|
$u->load($tmpFile);
|
||||||
@ -269,15 +284,18 @@ class UploadTest extends SapphireTest {
|
|||||||
'error' => UPLOAD_ERR_OK,
|
'error' => UPLOAD_ERR_OK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Make sure there are none here, otherwise they get renamed incorrectly for the test.
|
||||||
|
$this->deleteTestUploadFiles("/UploadTesttestUpload.*/");
|
||||||
|
|
||||||
$v = new UploadTest_Validator();
|
$v = new UploadTest_Validator();
|
||||||
$v->setAllowedExtensions(array(''));
|
$v->setAllowedExtensions(array(''));
|
||||||
|
|
||||||
// test upload into default folder
|
// test upload into default folder
|
||||||
$u = new Upload();
|
$u = new Upload();
|
||||||
$u->setValidator($v);
|
$u->setValidator($v);
|
||||||
$u->load($tmpFile);
|
$u->load($tmpFile);
|
||||||
$file = $u->getFile();
|
$file = $u->getFile();
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'UploadTesttestUpload',
|
'UploadTesttestUpload',
|
||||||
$file->Name,
|
$file->Name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user