[ticket/494] Correctly mock sql_save and sql_load methods of cache

B3P-494
This commit is contained in:
Marc Alexander
2015-03-04 10:23:37 +01:00
parent 1e405e9d91
commit 9fe7e17124
4 changed files with 36 additions and 4 deletions

View File

@@ -61,7 +61,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
$phpbb_container->setParameter('board3.portal.config.table', $table_prefix . 'portal_config'); $phpbb_container->setParameter('board3.portal.config.table', $table_prefix . 'portal_config');
$this->portal_columns = new \board3\portal\portal\columns(); $this->portal_columns = new \board3\portal\portal\columns();
$phpbb_container->set('board3.portal.columns', $this->portal_columns); $phpbb_container->set('board3.portal.columns', $this->portal_columns);
$cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put')); $cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put', 'sql_load', 'sql_save'));
$cache->expects($this->any()) $cache->expects($this->any())
->method('destroy') ->method('destroy')
->with($this->equalTo('portal_modules')); ->with($this->equalTo('portal_modules'));
@@ -75,6 +75,14 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
$cache->expects($this->any()) $cache->expects($this->any())
->method('put') ->method('put')
->with($this->anything()); ->with($this->anything());
$cache->expects($this->any())
->method('sql_load')
->with($this->anything())
->will($this->returnValue(false));
$cache->expects($this->any())
->method('sql_save')
->with($this->anything())
->will($this->returnArgument(2));
$db = $this->db; $db = $this->db;
$user->set(array( $user->set(array(
'UNABLE_TO_MOVE' => 'UNABLE_TO_MOVE', 'UNABLE_TO_MOVE' => 'UNABLE_TO_MOVE',

View File

@@ -29,7 +29,7 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
$user->add_lang('../../ext/board3/portal/language/en/portal'); $user->add_lang('../../ext/board3/portal/language/en/portal');
$request = new \phpbb_mock_request; $request = new \phpbb_mock_request;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions')); $cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions', 'sql_load', 'sql_save'));
$cache->expects($this->any()) $cache->expects($this->any())
->method('obtain_word_list') ->method('obtain_word_list')
->with() ->with()
@@ -38,6 +38,14 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
->method('get') ->method('get')
->with($this->anything()) ->with($this->anything())
->will($this->returnValue(false)); ->will($this->returnValue(false));
$cache->expects($this->any())
->method('sql_load')
->with($this->anything())
->will($this->returnValue(false));
$cache->expects($this->any())
->method('sql_save')
->with($this->anything())
->will($this->returnArgument(2));
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_content.php'); require_once(dirname(__FILE__) . '/../../../../../../includes/functions_content.php');
$this->config = new \phpbb\config\config(array('allow_attachments' => 1)); $this->config = new \phpbb\config\config(array('allow_attachments' => 1));
$auth = new \phpbb\auth\auth(); $auth = new \phpbb\auth\auth();

View File

@@ -29,7 +29,7 @@ class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\d
$user->add_lang('common'); $user->add_lang('common');
$user->add_lang('../../ext/board3/portal/language/en/portal'); $user->add_lang('../../ext/board3/portal/language/en/portal');
$phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions')); $cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions', 'sql_load', 'sql_save'));
$cache->expects($this->any()) $cache->expects($this->any())
->method('obtain_word_list') ->method('obtain_word_list')
->with() ->with()
@@ -38,6 +38,14 @@ class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\d
->method('get') ->method('get')
->with($this->anything()) ->with($this->anything())
->will($this->returnValue(false)); ->will($this->returnValue(false));
$cache->expects($this->any())
->method('sql_load')
->with($this->anything())
->will($this->returnValue(false));
$cache->expects($this->any())
->method('sql_save')
->with($this->anything())
->will($this->returnArgument(2));
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_content.php'); require_once(dirname(__FILE__) . '/../../../../../../includes/functions_content.php');
$this->config = new \phpbb\config\config(array('allow_attachments' => 1)); $this->config = new \phpbb\config\config(array('allow_attachments' => 1));
$auth = new \phpbb\auth\auth(); $auth = new \phpbb\auth\auth();

View File

@@ -44,7 +44,7 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew
)); ));
$this->portal_columns = new \board3\portal\portal\columns(); $this->portal_columns = new \board3\portal\portal\columns();
$cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put')); $cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put', 'sql_load', 'sql_save'));
$cache->expects($this->any()) $cache->expects($this->any())
->method('destroy') ->method('destroy')
->with($this->equalTo('portal_modules')); ->with($this->equalTo('portal_modules'));
@@ -58,6 +58,14 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew
$cache->expects($this->any()) $cache->expects($this->any())
->method('put') ->method('put')
->with($this->anything()); ->with($this->anything());
$cache->expects($this->any())
->method('sql_load')
->with($this->anything())
->will($this->returnValue(false));
$cache->expects($this->any())
->method('sql_save')
->with($this->anything())
->will($this->returnArgument(2));
$db = $this->db; $db = $this->db;
$user->set(array( $user->set(array(
'UNABLE_TO_MOVE' => 'UNABLE_TO_MOVE', 'UNABLE_TO_MOVE' => 'UNABLE_TO_MOVE',