diff options
author | Igor Wiedler <igor@wiedler.ch> | 2010-11-03 18:35:31 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-01-09 23:49:35 +0100 |
commit | 9329b16ab13f3a4caf107df358c3c58bda2dcd8a (patch) | |
tree | 0b5faa7111c792565062c93b1c1a44eda50d4664 /tests/class_loader | |
parent | 36e95f939db9b88b8519d956120d161102184ccb (diff) | |
download | forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar.gz forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar.bz2 forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.tar.xz forums-9329b16ab13f3a4caf107df358c3c58bda2dcd8a.zip |
[task/acm-refactor] Refactor the ACM classes to have a common interface.
They are now refered to as cache drivers rather than ACM classes. The
additional utility functions from the original cache class have been
moved to the cache_service. The class loader is now instantiated without
a cache instance and passed one as soon as it is constructed to allow
autoloading the cache classes.
PHPBB3-9983
Diffstat (limited to 'tests/class_loader')
-rw-r--r-- | tests/class_loader/cache_mock.php | 49 | ||||
-rw-r--r-- | tests/class_loader/class_loader_test.php | 14 |
2 files changed, 57 insertions, 6 deletions
diff --git a/tests/class_loader/cache_mock.php b/tests/class_loader/cache_mock.php index b254978fcc..73d1e64cf5 100644 --- a/tests/class_loader/cache_mock.php +++ b/tests/class_loader/cache_mock.php @@ -8,7 +8,9 @@ * */ -class phpbb_cache_mock +require '../phpBB/includes/cache/driver/interface.php'; + +class phpbb_cache_mock implements phpbb_cache_driver_interface { private $variables = array(); @@ -22,8 +24,51 @@ class phpbb_cache_mock return false; } - function put($var_name, $value) + function put($var_name, $value, $ttl = 0) { $this->variables[$var_name] = $value; } + + function load() + { + } + function unload() + { + } + function save() + { + } + function tidy() + { + } + function purge() + { + } + function destroy($var_name, $table = '') + { + } + public function _exists($var_name) + { + } + public function sql_load($query) + { + } + public function sql_save($query, &$query_result, $ttl) + { + } + public function sql_exists($query_id) + { + } + public function sql_fetchrow($query_id) + { + } + public function sql_fetchfield($query_id, $field) + { + } + public function sql_rowseek($rownum, $query_id) + { + } + public function sql_freeresult($query_id) + { + } } diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 3eb3c915a1..c01278f914 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -10,8 +10,6 @@ require_once __DIR__ . '/cache_mock.php'; -require_once __DIR__ . '/../../phpBB/includes/class_loader.php'; - class phpbb_class_loader_test extends PHPUnit_Framework_TestCase { public function setUp() @@ -63,8 +61,16 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase public function test_resolve_cached() { - $cache = new phpbb_cache_mock; - $cache->put('class_loader', array('phpbb_a_cached_name' => 'a/cached_name')); + $cacheMap = array('class_loader' => array('phpbb_a_cached_name' => 'a/cached_name')); + + $cache = $this->getMock('phpbb_cache_driver_interface', + array('get', 'put', 'load', 'unload', 'save', 'tidy', 'purge', 'destroy', '_exists', + 'sql_load', 'sql_save', 'sql_exists', 'sql_fetchrow', 'sql_fetchfield', 'sql_rowseek', 'sql_freeresult')); + $cache->expects($this->any()) + ->method('get') + ->will($this->returnCallback(function($var_name) use ($cacheMap) { + return $cacheMap[$var_name]; + })); $prefix = __DIR__ . '/'; $class_loader = new phpbb_class_loader($prefix, '.php', $cache); |