diff --git a/phpBB/phpbb/attachment/delete.php b/phpBB/phpbb/attachment/delete.php index a248d5a20b..5dddb06310 100644 --- a/phpBB/phpbb/attachment/delete.php +++ b/phpBB/phpbb/attachment/delete.php @@ -71,11 +71,12 @@ class delete * @param resync $resync * @param storage $storage */ - public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, resync $resync, $storage) + public function __construct(config $config, driver_interface $db, dispatcher $dispatcher, resync $resync, storage $storage) { $this->config = $config; $this->db = $db; $this->dispatcher = $dispatcher; + $this->resync = $resync; $this->storage = $storage; } @@ -411,7 +412,7 @@ class delete { if ($this->storage->exists($filename)) { - $this->storage->remove($filename); + $this->storage->delete($filename); return true; } } diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index 73007e120d..f5d307c5af 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -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')); } diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index f9fe050c7a..11f862c277 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -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() diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 4f978219c2..46c2f05aab 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -298,6 +298,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $adapter = new \phpbb\storage\adapter\local(new \phpbb\filesystem\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($adapter); + $storage = new \phpbb\storage\storage($adapter_factory_mock, ''); + // Create auth mock $auth = $this->createMock('\phpbb\auth\auth'); $auth->expects($this->any()) @@ -309,7 +317,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path); + $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage); $phpbb_dispatcher = new phpbb_mock_event_dispatcher();