1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-10 10:44:20 +02:00

[ticket/15286] Fix tests

PHPBB3-15286
This commit is contained in:
Rubén Calvo
2017-08-09 14:22:03 +02:00
parent ef43dbdcca
commit a176fa56ef
4 changed files with 25 additions and 35 deletions

View File

@@ -27,6 +27,9 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
/** @var \phpbb\attachment\resync */
protected $resync;
/** @var \phpbb\storage\storage */
protected $storage;
/** @var \phpbb\attachment\delete */
protected $attachment_delete;
@@ -52,15 +55,13 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
$this->filesystem->expects($this->any())
->method('exists')
->willReturn(true);
$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 = new \phpbb\storage\adapter\local($this->filesystem, $phpbb_root_path);
$adapter->configure(['path' => 'files']);
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');
$adapter_factory_mock->expects($this->any())
->method('get')
->willReturn($local_adapter);
$this->storage = new \phpbb\storage\storage($adapter_factory_mock, 'attachment');
->willReturn($adapter);
$this->storage = new \phpbb\storage\storage($adapter_factory_mock, '');
$this->dispatcher = new \phpbb_mock_event_dispatcher();
$this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage);
}
@@ -109,24 +110,6 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
*/
public function test_attachment_delete_success($remove_success, $exists_success, $expected, $throw_exception = false)
{
$this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists'));
if ($throw_exception)
{
$this->filesystem->expects($this->any())
->method('remove')
->willThrowException(new \phpbb\filesystem\exception\filesystem_exception);;
}
else
{
$this->filesystem->expects($this->any())
->method('remove')
->willReturn($remove_success);
}
$this->filesystem->expects($this->any())
->method('exists')
->willReturn($exists_success);
$this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage);
$this->assertSame($expected, $this->attachment_delete->unlink_attachment('foobar'));
}

View File

@@ -99,15 +99,13 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$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 = new \phpbb\storage\adapter\local($this->filesystem, $phpbb_root_path);
$adapter->configure(['path' => 'files']);
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');
$adapter_factory_mock->expects($this->any())
->method('get')
->willReturn($local_adapter);
$this->storage = new \phpbb\storage\storage($adapter_factory_mock, 'attachment');
->willReturn($adapter);
$this->storage = new \phpbb\storage\storage($adapter_factory_mock, '');
$factory_mock = $this->getMockBuilder('\phpbb\files\factory')
->disableOriginalConstructor()