mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-25 12:33:29 +01:00
Merge pull request #2432 from Nicofuma/ticket/11226
[ticket/11226] filespec::move_file() should error correctly * Nicofuma/ticket/11226: [ticket/11226] Explicity set file_moved to false [ticket/11226] Add tests [ticket/11226] Use $user->lang() [ticket/11226] filespec::move_file() should error correctly
This commit is contained in:
commit
cae8448fe4
@ -311,6 +311,9 @@ class filespec
|
||||
if (file_exists($this->destination_file) && !$overwrite)
|
||||
{
|
||||
@unlink($this->filename);
|
||||
$this->error[] = $user->lang($this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR', $this->destination_file);
|
||||
$this->file_moved = false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -107,6 +107,31 @@ class phpbb_fileupload_test extends phpbb_test_case
|
||||
unlink($this->path . 'jpg.jpg');
|
||||
}
|
||||
|
||||
public function test_move_existent_file()
|
||||
{
|
||||
$upload = new fileupload('', array('jpg'), 1000);
|
||||
|
||||
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
|
||||
$file = $upload->local_upload($this->path . 'jpg.jpg');
|
||||
$this->assertEquals(0, sizeof($file->error));
|
||||
$this->assertFalse($file->move_file('../tests/upload/fixture'));
|
||||
$this->assertFalse($file->file_moved);
|
||||
$this->assertEquals(1, sizeof($file->error));
|
||||
}
|
||||
|
||||
public function test_move_existent_file_overwrite()
|
||||
{
|
||||
$upload = new fileupload('', array('jpg'), 1000);
|
||||
|
||||
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
|
||||
copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg');
|
||||
$file = $upload->local_upload($this->path . 'jpg.jpg');
|
||||
$this->assertEquals(0, sizeof($file->error));
|
||||
$file->move_file('../tests/upload/fixture/copies', true);
|
||||
$this->assertEquals(0, sizeof($file->error));
|
||||
unlink($this->path . 'copies/jpg.jpg');
|
||||
}
|
||||
|
||||
public function test_valid_dimensions()
|
||||
{
|
||||
$upload = new fileupload('', false, false, 1, 1, 100, 100);
|
||||
|
Loading…
x
Reference in New Issue
Block a user