[ticket/10941] Added subdirectory for file operations

Also removed common.php as it was unnecessary.

PHPBB3-10941
This commit is contained in:
Fyorl 2012-07-08 14:39:18 +01:00
parent d89af53f63
commit 580cec619b
8 changed files with 8 additions and 22 deletions

View file

@ -52,15 +52,15 @@ class phpbb_filespec_test extends phpbb_test_case
$iterator = new DirectoryIterator($this->path); $iterator = new DirectoryIterator($this->path);
foreach ($iterator as $fileinfo) foreach ($iterator as $fileinfo)
{ {
if ($fileinfo->isDot()) if ($fileinfo->isDot() || $fileinfo->isDir())
{ {
continue; continue;
} }
copy($fileinfo->getPathname(), $this->path . $fileinfo->getFilename() . '_copy'); copy($fileinfo->getPathname(), $this->path . 'copies/' . $fileinfo->getFilename() . '_copy');
if ($fileinfo->getFilename() === 'txt') if ($fileinfo->getFilename() === 'txt')
{ {
copy($fileinfo->getPathname(), $this->path . $fileinfo->getFilename() . '_copy_2'); copy($fileinfo->getPathname(), $this->path . 'copies/' . $fileinfo->getFilename() . '_copy_2');
} }
} }
} }
@ -84,24 +84,10 @@ class phpbb_filespec_test extends phpbb_test_case
global $user; global $user;
$this->config = array(); $this->config = array();
$user = null; $user = null;
$files = array(
'gif_copy',
'jpg_copy',
'png_copy',
'txt_copy',
'txt_copy_2',
'tif_copy',
'gif_moved',
'jpg_moved',
'png_moved',
'txt_as_img',
'txt_moved',
);
foreach ($files as $file) foreach (glob($this->path . 'copies/*') as $file)
{ {
@unlink($this->path . $file); unlink($file);
} }
} }
@ -266,7 +252,7 @@ class phpbb_filespec_test extends phpbb_test_case
$upload->max_filesize = self::UPLOAD_MAX_FILESIZE; $upload->max_filesize = self::UPLOAD_MAX_FILESIZE;
$filespec = $this->get_filespec(array( $filespec = $this->get_filespec(array(
'tmp_name' => $this->path . $tmp_name, 'tmp_name' => $this->path . 'copies/' . $tmp_name,
'name' => $realname, 'name' => $realname,
'type' => $mime_type, 'type' => $mime_type,
)); ));
@ -274,8 +260,8 @@ class phpbb_filespec_test extends phpbb_test_case
$filespec->upload = $upload; $filespec->upload = $upload;
$filespec->local = true; $filespec->local = true;
$this->assertEquals($expected, $filespec->move_file($this->path)); $this->assertEquals($expected, $filespec->move_file($this->path . 'copies'));
$this->assertEquals($filespec->file_moved, file_exists($this->path . $realname)); $this->assertEquals($filespec->file_moved, file_exists($this->path . 'copies/' . $realname));
if ($error) if ($error)
{ {
$this->assertEquals($error, $filespec->error[0]); $this->assertEquals($error, $filespec->error[0]);

View file

Before

Width:  |  Height:  |  Size: 35 B

After

Width:  |  Height:  |  Size: 35 B

View file

Before

Width:  |  Height:  |  Size: 519 B

After

Width:  |  Height:  |  Size: 519 B

View file

Before

Width:  |  Height:  |  Size: 69 B

After

Width:  |  Height:  |  Size: 69 B