aboutsummaryrefslogtreecommitdiffstats
path: root/tests/upload/fileupload_test.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-07-15 16:08:20 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-09-09 08:27:58 +0200
commitadcc901af181b6727dd7af89a3926c9923a58471 (patch)
tree720561f2a804e91717124607c5a4e8701336b13d /tests/upload/fileupload_test.php
parentcf9b6ed4742f95b75125963935f4f2d9e9cfa62c (diff)
downloadforums-adcc901af181b6727dd7af89a3926c9923a58471.tar
forums-adcc901af181b6727dd7af89a3926c9923a58471.tar.gz
forums-adcc901af181b6727dd7af89a3926c9923a58471.tar.bz2
forums-adcc901af181b6727dd7af89a3926c9923a58471.tar.xz
forums-adcc901af181b6727dd7af89a3926c9923a58471.zip
[ticket/13904] Fix minor issues and move local_upload to its own class
PHPBB3-13904
Diffstat (limited to 'tests/upload/fileupload_test.php')
-rw-r--r--tests/upload/fileupload_test.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index c62e9a1947..7a84b34473 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -43,7 +43,7 @@ class phpbb_fileupload_test extends phpbb_test_case
if (!is_array($config))
{
- $config = array();
+ $config = new \phpbb\config\config(array());
}
$config['rand_seed'] = '';
@@ -53,6 +53,15 @@ class phpbb_fileupload_test extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
+ $guessers = array(
+ new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(),
+ new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(),
+ new \phpbb\mimetype\content_guesser(),
+ new \phpbb\mimetype\extension_guesser(),
+ );
+ $guessers[2]->set_priority(-2);
+ $guessers[3]->set_priority(-2);
+ $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers);
$this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx);
$this->container->set('files.filespec', new \phpbb\files\filespec(
@@ -63,6 +72,18 @@ class phpbb_fileupload_test extends phpbb_test_case
'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(),
))));
$this->factory = new \phpbb\files\factory($this->container);
+ $plupload = new \phpbb\plupload\plupload($phpbb_root_path, $config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), new \phpbb\php\ini(), $this->mimetype_guesser);
+ $this->container->set('files.types.form', new \phpbb\files\types\form(
+ $this->factory,
+ $this->language,
+ $plupload,
+ $this->request
+ ), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
+ $this->container->set('files.types.local', new \phpbb\files\types\local(
+ $this->factory,
+ $this->language,
+ $this->request
+ ), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
@@ -137,7 +158,7 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
- $file = $upload->local_upload($this->path . 'jpg.jpg');
+ $file = $upload->handle_upload('local', $this->path . 'jpg.jpg');
$this->assertEquals(0, sizeof($file->error));
unlink($this->path . 'jpg.jpg');
}
@@ -149,7 +170,7 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
- $file = $upload->local_upload($this->path . 'jpg.jpg');
+ $file = $upload->handle_upload('local', $this->path . 'jpg.jpg');
$this->assertEquals(0, sizeof($file->error));
$this->assertFalse($file->move_file('../tests/upload/fixture'));
$this->assertFalse($file->file_moved);
@@ -164,7 +185,7 @@ class phpbb_fileupload_test extends phpbb_test_case
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');
+ $file = $upload->handle_upload('local', $this->path . 'jpg.jpg');
$this->assertEquals(0, sizeof($file->error));
$file->move_file('../tests/upload/fixture/copies', true);
$this->assertEquals(0, sizeof($file->error));