mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 13:58:54 +00:00
[ticket/15342] Fix test
PHPBB3-15342
This commit is contained in:
parent
22b2e95531
commit
f9c1901317
9 changed files with 21 additions and 24 deletions
|
@ -30,7 +30,7 @@ class storage_track extends \phpbb\db\migration\migration
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'add_tables' => array(
|
'add_tables' => array(
|
||||||
STORAGE_TABLE => array(
|
$this->table_prefix . 'storage' => array(
|
||||||
'COLUMNS' => array(
|
'COLUMNS' => array(
|
||||||
'file_id' => array('UINT', null, 'auto_increment'),
|
'file_id' => array('UINT', null, 'auto_increment'),
|
||||||
'file_path' => array('VCHAR', ''),
|
'file_path' => array('VCHAR', ''),
|
||||||
|
@ -93,7 +93,7 @@ class storage_track extends \phpbb\db\migration\migration
|
||||||
{
|
{
|
||||||
$storage->track_file($row['physical_filename']);
|
$storage->track_file($row['physical_filename']);
|
||||||
|
|
||||||
if($row['thumbnail'] == 1)
|
if ($row['thumbnail'] == 1)
|
||||||
{
|
{
|
||||||
$storage->track_file('thumb_' . $row['physical_filename']);
|
$storage->track_file('thumb_' . $row['physical_filename']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,11 @@ class storage
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param \phpbb\cache\driver\driver_interface $db
|
|
||||||
* @param \phpbb\db\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 \phpbb\storage\adapter_factory $factory
|
||||||
* @param string $storage_name
|
* @param string $storage_name
|
||||||
|
* @param string $storage_table
|
||||||
*/
|
*/
|
||||||
public function __construct(db $db, cache $cache, adapter_factory $factory, $storage_name, $storage_table)
|
public function __construct(db $db, cache $cache, adapter_factory $factory, $storage_name, $storage_table)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,9 +44,10 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$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 = $this->db;
|
$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->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists'));
|
||||||
$this->filesystem->expects($this->any())
|
$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())
|
$adapter_factory_mock->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($adapter);
|
->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->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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,9 @@ 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();
|
||||||
|
@ -109,7 +111,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
|
||||||
$adapter_factory_mock->expects($this->any())
|
$adapter_factory_mock->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($adapter);
|
->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')
|
$factory_mock = $this->getMockBuilder('\phpbb\files\factory')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
|
|
@ -30,6 +30,8 @@ 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')
|
||||||
|
@ -43,11 +45,10 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||||
$adapter_factory_mock->expects($this->any())
|
$adapter_factory_mock->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($adapter);
|
->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
|
// 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()
|
||||||
|
|
|
@ -304,7 +304,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
|
||||||
$adapter_factory_mock->expects($this->any())
|
$adapter_factory_mock->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($adapter);
|
->willReturn($adapter);
|
||||||
$storage = new \phpbb\storage\storage($adapter_factory_mock, '');
|
$storage = $this->createMock('\phpbb\storage\storage');
|
||||||
|
|
||||||
// Create auth mock
|
// Create auth mock
|
||||||
$auth = $this->createMock('\phpbb\auth\auth');
|
$auth = $this->createMock('\phpbb\auth\auth');
|
||||||
|
|
|
@ -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 = 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, $adapter_factory_mock, '', '');
|
|
||||||
|
|
||||||
// Works as a workaround for tests
|
// 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));
|
$phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage));
|
||||||
|
|
|
@ -56,6 +56,7 @@ 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');
|
||||||
|
@ -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));
|
$lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
|
||||||
|
|
||||||
// Storage
|
// 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);
|
$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, $adapter_factory_mock, '', '');
|
|
||||||
|
|
||||||
// User
|
// User
|
||||||
$user = $this->createMock('\phpbb\user', array(), array(
|
$user = $this->createMock('\phpbb\user', array(), array(
|
||||||
|
|
|
@ -87,7 +87,10 @@ 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());
|
||||||
|
@ -98,7 +101,7 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case
|
||||||
$adapter_factory_mock->expects($this->any())
|
$adapter_factory_mock->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($adapter);
|
->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
|
// 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));
|
||||||
|
|
Loading…
Add table
Reference in a new issue