mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/14168] Add tests for init_error() during upload
PHPBB3-14168
This commit is contained in:
parent
8a6224bf8a
commit
6c80fd92c6
1 changed files with 49 additions and 0 deletions
|
@ -180,4 +180,53 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
|
|||
|
||||
$this->assertSame($expected, $filedata);
|
||||
}
|
||||
|
||||
public function test_init_error()
|
||||
{
|
||||
$filespec = $this->getMockBuilder('\phpbb\files\filespec')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$filespec->expects($this->any())
|
||||
->method('init_error')
|
||||
->willReturn(true);
|
||||
$filespec->expects($this->any())
|
||||
->method('set_upload_namespace')
|
||||
->willReturnSelf();
|
||||
$filespec->expects($this->any())
|
||||
->method('set_upload_ary')
|
||||
->willReturnSelf();
|
||||
$this->container->set('files.filespec', $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(
|
||||
$factory_mock,
|
||||
$this->language,
|
||||
$this->php_ini,
|
||||
$this->request
|
||||
));
|
||||
|
||||
$this->upload = new \phpbb\attachment\upload(
|
||||
$this->auth,
|
||||
$this->cache,
|
||||
$this->config,
|
||||
$this->files_upload,
|
||||
$this->language,
|
||||
$this->mimetype_guesser,
|
||||
$this->phpbb_dispatcher,
|
||||
$this->plupload,
|
||||
$this->user,
|
||||
$this->phpbb_root_path
|
||||
);
|
||||
|
||||
$filedata = $this->upload->upload('foobar', 1, true);
|
||||
|
||||
$this->assertSame(array(
|
||||
'error' => array(),
|
||||
'post_attach' => false,
|
||||
), $filedata);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue