1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-18 22:41:28 +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

@@ -15,7 +15,6 @@ class phpbb_filespec_test extends phpbb_test_case
{
const TEST_COUNT = 100;
const PREFIX = 'phpbb_';
const MAX_STR_LEN = 50;
const UPLOAD_MAX_FILESIZE = 1000;
private $config;
@@ -28,6 +27,8 @@ class phpbb_filespec_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
protected $mimetype_guesser;
protected function setUp(): void
{
// Global $config required by unique_id
@@ -374,7 +375,7 @@ class phpbb_filespec_test extends phpbb_test_case
public function test_move_file($tmp_name, $realname, $mime_type, $extension, $error, $expected)
{
// Global $phpbb_root_path and $phpEx are required by phpbb_chmod
global $phpbb_root_path, $phpEx;
global $phpbb_root_path;
$this->phpbb_root_path = '';
$upload = new phpbb_mock_fileupload();

View File

@@ -17,6 +17,7 @@ class phpbb_fileupload_test extends phpbb_test_case
{
private $path;
/** @var \phpbb\filesystem\filesystem */
private $filesystem;
/** @var \Symfony\Component\DependencyInjection\ContainerInterface */
@@ -37,6 +38,8 @@ class phpbb_fileupload_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
protected $mimetype_guesser;
protected function setUp(): void
{
// Global $config required by unique_id
@@ -117,7 +120,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_invalid_extension()
{
$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'))
->set_max_filesize(100);
$file = $this->gen_valid_filespec();
@@ -127,7 +130,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_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);
$upload->set_allowed_extensions(array('jpg'))
->set_max_filesize(1000);
$file = new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path);
@@ -146,7 +149,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_invalid_filename()
{
$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('jpg'))
->set_max_filesize(100);
$file = $this->gen_valid_filespec();
@@ -157,7 +160,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_too_large()
{
$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('jpg'))
->set_max_filesize(100);
$file = $this->gen_valid_filespec();
@@ -168,7 +171,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_valid_file()
{
$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('jpg'))
->set_max_filesize(1000);
$file = $this->gen_valid_filespec();
@@ -178,7 +181,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_local_upload()
{
$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('jpg'))
->set_max_filesize(1000);
@@ -192,7 +195,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_move_existent_file()
{
$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('jpg'))
->set_max_filesize(1000);
@@ -206,7 +209,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_move_existent_file_overwrite()
{
$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('jpg'))
->set_max_filesize(1000);
@@ -221,7 +224,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_valid_dimensions()
{
$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);
$upload->set_allowed_extensions(false)
->set_max_filesize(false)
->set_allowed_dimensions(1, 1, 100, 100);

View File

@@ -20,7 +20,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case
/** @var string Path to fixtures */
protected $path;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->imagesize = new \FastImageSize\FastImageSize();