[ticket/15692] Update tests

PHPBB3-15692
This commit is contained in:
Rubén Calvo 2018-08-07 00:23:47 +02:00
parent 5fbe929a1d
commit d0b7875b18
5 changed files with 9 additions and 47 deletions

View file

@ -21,9 +21,6 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
/** @var \phpbb\db\driver\driver_interface */ /** @var \phpbb\db\driver\driver_interface */
protected $db; protected $db;
/** @var \phpbb\filesystem\filesystem */
protected $filesystem;
/** @var \phpbb\attachment\resync */ /** @var \phpbb\attachment\resync */
protected $resync; protected $resync;
@ -47,22 +44,11 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
$cache = $this->createMock('\phpbb\cache\driver\driver_interface'); $cache = $this->createMock('\phpbb\cache\driver\driver_interface');
$this->config = new \phpbb\config\config(array()); $this->config = new \phpbb\config\config(array());
$this->db = $this->new_dbal(); $this->db = $this->new_dbal();
$db_mock = $this->createMock('\phpbb\db\driver\driver_interface');
$this->resync = new \phpbb\attachment\resync($this->db); $this->resync = new \phpbb\attachment\resync($this->db);
$this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists')); $this->storage = $this->createMock('\phpbb\storage\storage');
$this->filesystem->expects($this->any()) $this->storage->expects($this->any())
->method('remove')
->willReturn(false);
$this->filesystem->expects($this->any())
->method('exists') ->method('exists')
->willReturn(true); ->willReturn(true);
$adapter = new \phpbb\storage\adapter\local($this->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);
$this->storage = new \phpbb\storage\storage($db_mock, $cache, $adapter_factory_mock, '', '');
$this->dispatcher = new \phpbb_mock_event_dispatcher(); $this->dispatcher = new \phpbb_mock_event_dispatcher();
$this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage); $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage);
} }

View file

@ -86,9 +86,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
)); ));
$config = $this->config; $config = $this->config;
$this->db = $this->new_dbal(); $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); $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->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem();
@ -105,13 +103,10 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); $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); $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);
$adapter = new \phpbb\storage\adapter\local($this->filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path); $this->storage = $this->createMock('\phpbb\storage\storage');
$adapter->configure(['path' => 'files']); $this->storage->expects($this->any())
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory'); ->method('free_space')
$adapter_factory_mock->expects($this->any()) ->willReturn(1024*1024); // 1gb
->method('get')
->willReturn($adapter);
$this->storage = new \phpbb\storage\storage($db_mock, $cache_mock, $adapter_factory_mock, '', '');
$factory_mock = $this->getMockBuilder('\phpbb\files\factory') $factory_mock = $this->getMockBuilder('\phpbb\files\factory')
->disableOriginalConstructor() ->disableOriginalConstructor()

View file

@ -30,25 +30,16 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
global $phpbb_root_path, $phpEx; global $phpbb_root_path, $phpEx;
// Mock phpbb_container // Mock phpbb_container
$cache = $this->createMock('\phpbb\cache\driver\driver_interface');
$phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container->expects($this->any()) $phpbb_container->expects($this->any())
->method('get') ->method('get')
->will($this->returnArgument(0)); ->will($this->returnArgument(0));
$filesystem = new \phpbb\filesystem\filesystem(); $storage = $this->createMock('\phpbb\storage\storage');
$adapter = new \phpbb\storage\adapter\local($filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path);
$adapter->configure(['path' => 'images/avatars/upload']);
$db = $this->createMock('\phpbb\db\driver\driver_interface');
$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, $cache, $adapter_factory_mock, '', '');
// Prepare dependencies for avatar manager and driver // Prepare dependencies for avatar manager and driver
$this->config = new \phpbb\config\config(array()); $this->config = new \phpbb\config\config(array());
$cache = $this->createMock('\phpbb\cache\driver\driver_interface');
$path_helper = new \phpbb\path_helper( $path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request( new \phpbb\symfony_request(
new phpbb_mock_request() new phpbb_mock_request()

View file

@ -56,7 +56,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
// Database // Database
$this->db = $this->new_dbal(); $this->db = $this->new_dbal();
$db = $this->db; $db = $this->db;
$db_mock = $this->createMock('\phpbb\db\driver\driver_interface');
// Auth // Auth
$auth = $this->createMock('\phpbb\auth\auth'); $auth = $this->createMock('\phpbb\auth\auth');

View file

@ -87,21 +87,12 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case
{ {
global $db, $phpbb_container, $phpbb_root_path; global $db, $phpbb_container, $phpbb_root_path;
$cache = $this->createMock('\phpbb\cache\driver\driver_interface');
$db = $this->new_dbal(); $db = $this->new_dbal();
$db_mock = $this->createMock('\phpbb\db\driver\driver_interface');
$phpbb_container = new phpbb_mock_container_builder(); $phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); $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); $storage = $this->createMock('\phpbb\storage\storage');
$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_mock, $cache, $adapter_factory_mock, '', '');
// Works as a workaround for tests // 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)); $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));