diff --git a/phpBB/phpbb/db/migration/data/v330/storage_track.php b/phpBB/phpbb/db/migration/data/v330/storage_track.php index c3f8d128ec..0c4f620c28 100644 --- a/phpBB/phpbb/db/migration/data/v330/storage_track.php +++ b/phpBB/phpbb/db/migration/data/v330/storage_track.php @@ -30,7 +30,7 @@ class storage_track extends \phpbb\db\migration\migration { return array( 'add_tables' => array( - STORAGE_TABLE => array( + $this->table_prefix . 'storage' => array( 'COLUMNS' => array( 'file_id' => array('UINT', null, 'auto_increment'), 'file_path' => array('VCHAR', ''), @@ -93,7 +93,7 @@ class storage_track extends \phpbb\db\migration\migration { $storage->track_file($row['physical_filename']); - if($row['thumbnail'] == 1) + if ($row['thumbnail'] == 1) { $storage->track_file('thumb_' . $row['physical_filename']); } diff --git a/phpBB/phpbb/storage/storage.php b/phpBB/phpbb/storage/storage.php index 327bb60ab1..63369af7e8 100644 --- a/phpBB/phpbb/storage/storage.php +++ b/phpBB/phpbb/storage/storage.php @@ -55,10 +55,11 @@ class storage /** * Constructor * - * @param \phpbb\cache\driver\driver_interface $db * @param \phpbb\db\driver\driver_interface $db + * @param \phpbb\cache\driver\driver_interface $cache * @param \phpbb\storage\adapter_factory $factory * @param string $storage_name + * @param string $storage_table */ public function __construct(db $db, cache $cache, adapter_factory $factory, $storage_name, $storage_table) { diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index 0718281d59..35dbf5d47d 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -44,9 +44,10 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case parent::setUp(); + $cache = $this->createMock('\phpbb\cache\driver\driver_interface'); $this->config = new \phpbb\config\config(array()); $this->db = $this->new_dbal(); - $db = $this->db; + $db_mock = $this->createMock('\phpbb\db\driver\driver_interface'); $this->resync = new \phpbb\attachment\resync($this->db); $this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists')); $this->filesystem->expects($this->any()) @@ -61,7 +62,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case $adapter_factory_mock->expects($this->any()) ->method('get') ->willReturn($adapter); - $this->storage = new \phpbb\storage\storage($db, $adapter_factory_mock, '', ''); + $this->storage = new \phpbb\storage\storage($db_mock, $cache, $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); } diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index a9567510c8..f1df81bc8a 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -86,7 +86,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case )); $config = $this->config; $this->db = $this->new_dbal(); + $db_mock = $this->createMock('\phpbb\db\driver\driver_interface'); $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx); + $cache_mock = $this->createMock('\phpbb\cache\driver\driver_interface'); $this->request = $this->createMock('\phpbb\request\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); @@ -109,7 +111,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $adapter_factory_mock->expects($this->any()) ->method('get') ->willReturn($adapter); - $this->storage = new \phpbb\storage\storage($adapter_factory_mock, ''); + $this->storage = new \phpbb\storage\storage($db_mock, $cache_mock, $adapter_factory_mock, '', ''); $factory_mock = $this->getMockBuilder('\phpbb\files\factory') ->disableOriginalConstructor() diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 30ef42e835..c390eac883 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -30,6 +30,8 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case global $phpbb_root_path, $phpEx; // Mock phpbb_container + + $cache = $this->createMock('\phpbb\cache\driver\driver_interface'); $phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container->expects($this->any()) ->method('get') @@ -43,11 +45,10 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case $adapter_factory_mock->expects($this->any()) ->method('get') ->willReturn($adapter); - $storage = new \phpbb\storage\storage($db, $adapter_factory_mock, '', ''); + $storage = new \phpbb\storage\storage($db, $cache, $adapter_factory_mock, '', ''); // Prepare dependencies for avatar manager and driver $this->config = new \phpbb\config\config(array()); - $cache = $this->createMock('\phpbb\cache\driver\driver_interface'); $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index d4feeaad22..9454c90202 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -304,7 +304,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $adapter_factory_mock->expects($this->any()) ->method('get') ->willReturn($adapter); - $storage = new \phpbb\storage\storage($adapter_factory_mock, ''); + $storage = $this->createMock('\phpbb\storage\storage'); // Create auth mock $auth = $this->createMock('\phpbb\auth\auth'); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 489aec01cf..e6610cbabb 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -35,13 +35,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $adapter = new \phpbb\storage\adapter\local(new \phpbb\filesystem\filesystem(), new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $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($db, $adapter_factory_mock, '', ''); + $storage = $this->createMock('\phpbb\storage\storage'); // Works as a workaround for tests $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage)); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index db65c5df07..255d52bde0 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -56,6 +56,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Database $this->db = $this->new_dbal(); $db = $this->db; + $db_mock = $this->createMock('\phpbb\db\driver\driver_interface'); // Auth $auth = $this->createMock('\phpbb\auth\auth'); @@ -92,13 +93,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); // Storage - $adapter = new \phpbb\storage\adapter\local(new \phpbb\filesystem\filesystem(), new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $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($db, $adapter_factory_mock, '', ''); + $storage = $this->createMock('\phpbb\storage\storage'); // User $user = $this->createMock('\phpbb\user', array(), array( diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index b35510113a..50761d72ca 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -87,7 +87,10 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case { global $db, $phpbb_container, $phpbb_root_path; + $cache = $this->createMock('\phpbb\cache\driver\driver_interface'); + $db = $this->new_dbal(); + $db_mock = $this->createMock('\phpbb\db\driver\driver_interface'); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); @@ -98,7 +101,7 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case $adapter_factory_mock->expects($this->any()) ->method('get') ->willReturn($adapter); - $storage = new \phpbb\storage\storage($adapter_factory_mock, ''); + $storage = new \phpbb\storage\storage($db_mock, $cache, $adapter_factory_mock, '', ''); // Works as a workaround for tests $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage));