1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-25 01:51:21 +01:00

[ticket/15286] Fix tests

PHPBB3-15286
This commit is contained in:
Rubén Calvo 2017-08-09 14:22:03 +02:00
parent e749e06042
commit e564ca6e60
4 changed files with 28 additions and 20 deletions

View File

@ -158,7 +158,6 @@ function send_file_to_browser($attachment, $category)
$size = 0;
}
/**
* Event to alter attachment before it is sent to browser.
*

View File

@ -293,7 +293,7 @@ class upload
$this->file_data['error'][] = $this->language->lang('ATTACH_QUOTA_REACHED');
$this->file_data['post_attach'] = false;
$this->file->remove();
$this->file->remove($this->storage);
return false;
}

View File

@ -19,7 +19,7 @@ use phpbb\files\filespec;
use phpbb\language\language;
use phpbb\request\request_interface;
class local extends base
class local_storage extends base
{
/** @var factory Files factory */
protected $factory;

View File

@ -39,6 +39,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
/** @var \phpbb\plupload\plupload */
protected $plupload;
/** @var \phpbb\storage\storage */
protected $storage;
/** @var \phpbb\user */
protected $user;
@ -75,7 +78,6 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->auth = new \phpbb\auth\auth();
$this->config = new \phpbb\config\config(array(
'upload_path' => '',
'img_create_thumbnail' => true,
));
$config = $this->config;
@ -96,27 +98,34 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$guessers[3]->set_priority(-2);
$this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers);
$this->plupload = new \phpbb\plupload\plupload($phpbb_root_path, $this->config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), $this->php_ini, $this->mimetype_guesser);
$local_adapter = new \phpbb\storage\adapter\local($this->filesystem, $phpbb_root_path);
$local_adapter->configure(['path' => 'files']);
$adapter_factory_mock = $this->getMockBuilder('\phpbb\storage\adapter_factory')
->disableOriginalConstructor()
->getMock();
$adapter_factory_mock->expects($this->any())
->method('get')
->willReturn($local_adapter);
$this->storage = new \phpbb\storage\storage($adapter_factory_mock, 'attachment');
$factory_mock = $this->getMockBuilder('\phpbb\files\factory')
->disableOriginalConstructor()
->getMock();
$factory_mock->expects($this->any())
->method('get')
->willReturn(new \phpbb\files\filespec(
$this->filesystem,
->willReturn(new \phpbb\files\filespec_storage(
$this->language,
$this->php_ini,
new \FastImageSize\FastImageSize(),
$this->phpbb_root_path,
$this->mimetype_guesser
));
$this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx);
$this->container->set('files.filespec', new \phpbb\files\filespec(
$this->filesystem,
$this->container->set('files.filespec_storage', new \phpbb\files\filespec_storage(
$this->language,
$this->php_ini,
new \FastImageSize\FastImageSize(),
$phpbb_root_path,
new \phpbb\mimetype\guesser(array(
'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(),
))));
@ -127,7 +136,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->plupload,
$this->request
));
$this->container->set('files.types.local', new \phpbb\files\types\local(
$this->container->set('files.types.local_storage', new \phpbb\files\types\local_storage(
$factory_mock,
$this->language,
$this->php_ini,
@ -138,7 +147,6 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
$this->upload = new \phpbb\attachment\upload(
$this->auth,
$this->cache,
@ -148,6 +156,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->mimetype_guesser,
$this->phpbb_dispatcher,
$this->plupload,
$this->storage,
$this->user,
$this->phpbb_root_path
);
@ -205,7 +214,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
public function test_init_error()
{
$filespec = $this->getMockBuilder('\phpbb\files\filespec')
$filespec = $this->getMockBuilder('\phpbb\files\filespec_storage')
->disableOriginalConstructor()
->getMock();
$filespec->expects($this->any())
@ -217,14 +226,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$filespec->expects($this->any())
->method('set_upload_ary')
->willReturnSelf();
$this->container->set('files.filespec', $filespec);
$this->container->set('files.filespec_storage', $filespec);
$factory_mock = $this->getMockBuilder('\phpbb\files\factory')
->disableOriginalConstructor()
->getMock();
$factory_mock->expects($this->any())
->method('get')
->willReturn($filespec);
$this->container->set('files.types.local', new \phpbb\files\types\local(
$this->container->set('files.types.local_storage', new \phpbb\files\types\local_storage(
$factory_mock,
$this->language,
$this->php_ini,
@ -240,6 +249,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->mimetype_guesser,
$this->phpbb_dispatcher,
$this->plupload,
$this->storage,
$this->user,
$this->phpbb_root_path
);
@ -336,7 +346,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
*/
public function test_image_upload($is_image, $plupload_active, $config_data, $expected)
{
$filespec = $this->getMockBuilder('\phpbb\files\filespec')
$filespec = $this->getMockBuilder('\phpbb\files\filespec_storage')
->setMethods(array(
'init_error',
'is_image',
@ -344,11 +354,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
'is_uploaded',
))
->setConstructorArgs(array(
$this->filesystem,
$this->language,
$this->php_ini,
new \FastImageSize\FastImageSize(),
$this->phpbb_root_path,
$this->mimetype_guesser,
$this->plupload
))
@ -370,14 +378,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$filespec->expects($this->any())
->method('move_file')
->willReturn(false);
$this->container->set('files.filespec', $filespec);
$this->container->set('files.filespec_storage', $filespec);
$factory_mock = $this->getMockBuilder('\phpbb\files\factory')
->disableOriginalConstructor()
->getMock();
$factory_mock->expects($this->any())
->method('get')
->willReturn($filespec);
$this->container->set('files.types.local', new \phpbb\files\types\local(
$this->container->set('files.types.local_storage', new \phpbb\files\types\local_storage(
$factory_mock,
$this->language,
$this->php_ini,
@ -406,6 +414,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->mimetype_guesser,
$this->phpbb_dispatcher,
$plupload,
$this->storage,
$this->user,
$this->phpbb_root_path
);