1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/16345] Small improvements

PHPBB3-16346
This commit is contained in:
rubencm
2020-06-07 02:15:35 +00:00
parent 3cceeb45bf
commit 774c609c4a
284 changed files with 1380 additions and 835 deletions

View File

@@ -13,8 +13,7 @@
class phpbb_files_types_base_test extends phpbb_test_case
{
private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem;
/** @var \Symfony\Component\DependencyInjection\ContainerInterface */
@@ -32,9 +31,6 @@ class phpbb_files_types_base_test extends phpbb_test_case
/** @var \phpbb\request\request_interface */
protected $request;
/** @var string phpBB root path */
protected $phpbb_root_path;
protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
@@ -56,9 +52,6 @@ class phpbb_files_types_base_test extends phpbb_test_case
'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(),
))));
$this->factory = new \phpbb\files\factory($this->container);
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
}
public function data_check_upload_size()
@@ -79,7 +72,7 @@ class phpbb_files_types_base_test extends phpbb_test_case
$php_ini->expects($this->any())
->method('getString')
->willReturn($max_filesize);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $php_ini, $this->request);
$upload = new \phpbb\files\upload($this->factory, $this->language, $php_ini, $this->request);
$type_form = new \phpbb\files\types\local($this->factory, $this->language, $php_ini, $this->request);
$file = $this->getMockBuilder('\phpbb\files\filespec')
->disableOriginalConstructor()

View File

@@ -13,8 +13,7 @@
class phpbb_files_types_form_test extends phpbb_test_case
{
private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem;
/** @var \Symfony\Component\DependencyInjection\ContainerInterface */
@@ -69,7 +68,6 @@ class phpbb_files_types_form_test extends phpbb_test_case
->method('handle_upload')
->willReturn(array());
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
}
@@ -160,7 +158,7 @@ class phpbb_files_types_form_test extends phpbb_test_case
->willReturn($plupload);
$type_form = new \phpbb\files\types\form($this->factory, $this->language, $this->php_ini, $this->plupload, $this->request);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_form->set_upload($upload);

View File

@@ -13,8 +13,7 @@
class phpbb_files_types_local_test extends phpbb_test_case
{
private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem;
/** @var \Symfony\Component\DependencyInjection\ContainerInterface */
@@ -69,7 +68,6 @@ class phpbb_files_types_local_test extends phpbb_test_case
->method('handle_upload')
->willReturn(array());
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
}
@@ -149,7 +147,7 @@ class phpbb_files_types_local_test extends phpbb_test_case
$this->factory = new \phpbb\files\factory($this->container);
$type_local = new \phpbb\files\types\local($this->factory, $this->language, $this->php_ini, $this->request);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_local->set_upload($upload);

View File

@@ -15,9 +15,6 @@ require_once dirname(__FILE__) . '/type_foo.php';
class phpbb_files_types_remote_test extends phpbb_test_case
{
/** @var string */
private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem;
@@ -72,14 +69,13 @@ class phpbb_files_types_remote_test extends phpbb_test_case
))));
$this->factory = new \phpbb\files\factory($this->container);
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
}
public function test_upload_fsock_fail()
{
$type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->temp, $this->language, $this->php_ini, $this->request);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload);
@@ -114,7 +110,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
->method('getString')
->willReturn($max_file_size);
$type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->temp, $this->language, $php_ini, $this->request);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload);
@@ -126,7 +122,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
public function test_upload_wrong_path()
{
$type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->temp, $this->language, $this->php_ini, $this->request);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload);
$type_remote::$tempnam_path = $this->phpbb_root_path . 'cache/wrong/path';

View File

@@ -13,8 +13,7 @@
class phpbb_files_upload_test extends phpbb_test_case
{
private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem;
/** @var \Symfony\Component\DependencyInjection\ContainerInterface */
@@ -66,13 +65,12 @@ class phpbb_files_upload_test extends phpbb_test_case
))));
$this->factory = new \phpbb\files\factory($this->container);
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
}
public function test_reset_vars()
{
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_max_filesize(500);
$this->assertEquals(500, $upload->max_filesize);
$upload->reset_vars();
@@ -81,7 +79,7 @@ class phpbb_files_upload_test extends phpbb_test_case
public function test_set_disallowed_content()
{
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$disallowed_content = new ReflectionProperty($upload, 'disallowed_content');
$disallowed_content->setAccessible(true);
@@ -89,7 +87,7 @@ class phpbb_files_upload_test extends phpbb_test_case
$this->assertEquals(array('foo'), $disallowed_content->getValue($upload));
$upload->set_disallowed_content(array('foo', 'bar', 'meh'));
$this->assertEquals(array('foo', 'bar', 'meh'), $disallowed_content->getValue($upload));
$upload->set_disallowed_content('');
$upload->set_disallowed_content(false);
$this->assertEquals(array('foo', 'bar', 'meh'), $disallowed_content->getValue($upload));
$this->assertINstanceOf('\phpbb\files\upload', $upload->set_disallowed_content(array()));
$this->assertEquals(array(), $disallowed_content->getValue($upload));
@@ -99,7 +97,7 @@ class phpbb_files_upload_test extends phpbb_test_case
public function test_is_valid()
{
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$this->assertFalse($upload->is_valid('foobar'));
}
@@ -122,7 +120,7 @@ class phpbb_files_upload_test extends phpbb_test_case
*/
public function test_assign_internal_error($error_code, $expected)
{
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$this->assertSame($expected, $upload->assign_internal_error($error_code));
}
}