mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-10 10:44:20 +02:00
[ticket/15286] Update tests
PHPBB3-15286
This commit is contained in:
@@ -55,7 +55,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
|
||||
$this->filesystem->expects($this->any())
|
||||
->method('exists')
|
||||
->willReturn(true);
|
||||
$adapter = new \phpbb\storage\adapter\local($this->filesystem, $phpbb_root_path);
|
||||
$adapter = new \phpbb\storage\adapter\local($this->filesystem, new \FastImageSize\FastImageSize(), $phpbb_root_path);
|
||||
$adapter->configure(['path' => 'files']);
|
||||
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');
|
||||
$adapter_factory_mock->expects($this->any())
|
||||
@@ -110,6 +110,23 @@ 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->storage = $this->createMock('\phpbb\storage\storage', array('delete', 'exists'));
|
||||
if ($throw_exception)
|
||||
{
|
||||
$this->storage->expects($this->any())
|
||||
->method('delete')
|
||||
->willThrowException(new \phpbb\storage\exception\exception);;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->storage->expects($this->any())
|
||||
->method('delete')
|
||||
->willReturn($remove_success);
|
||||
}
|
||||
$this->storage->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'));
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ 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);
|
||||
|
||||
$adapter = new \phpbb\storage\adapter\local($this->filesystem, $phpbb_root_path);
|
||||
$adapter = new \phpbb\storage\adapter\local($this->filesystem, new \FastImageSize\FastImageSize(), $phpbb_root_path);
|
||||
$adapter->configure(['path' => 'files']);
|
||||
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');
|
||||
$adapter_factory_mock->expects($this->any())
|
||||
|
@@ -298,7 +298,7 @@ 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 = new \phpbb\storage\adapter\local(new \phpbb\filesystem\filesystem(), new \FastImageSize\FastImageSize(), $phpbb_root_path);
|
||||
$adapter->configure(['path' => 'files']);
|
||||
$adapter_factory_mock = $this->createMock('\phpbb\storage\adapter_factory');
|
||||
$adapter_factory_mock->expects($this->any())
|
||||
|
@@ -34,8 +34,17 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$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(), $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, '');
|
||||
|
||||
// Works as a workaround for tests
|
||||
$phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path));
|
||||
$phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage));
|
||||
$phpbb_container->set(
|
||||
'auth.provider.db',
|
||||
new phpbb_mock_auth_provider()
|
||||
|
@@ -91,6 +91,15 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||
// Language
|
||||
$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(), $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, '');
|
||||
|
||||
// User
|
||||
$user = $this->createMock('\phpbb\user', array(), array(
|
||||
$lang,
|
||||
@@ -125,6 +134,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
|
||||
$phpbb_container->set('cache', $cache);
|
||||
$phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils());
|
||||
$phpbb_container->set('dispatcher', $phpbb_dispatcher);
|
||||
$phpbb_container->set('storage.attachment', $storage);
|
||||
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
|
||||
$phpbb_container->setParameter('core.php_ext', $phpEx);
|
||||
$phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');
|
||||
|
@@ -91,8 +91,17 @@ class phpbb_privmsgs_delete_user_pms_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(), $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, '');
|
||||
|
||||
// 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\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path));
|
||||
$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_delete_user_pms($delete_user);
|
||||
|
||||
|
Reference in New Issue
Block a user