From 36e95f939db9b88b8519d956120d161102184ccb Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 7 Jan 2011 18:03:00 +0100 Subject: [ticket/9979] Support autoloading in unit tests PHPBB-9979 --- tests/class_loader/class_loader_test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/class_loader/class_loader_test.php') diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index aef4f1de07..3eb3c915a1 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -14,6 +14,18 @@ require_once __DIR__ . '/../../phpBB/includes/class_loader.php'; class phpbb_class_loader_test extends PHPUnit_Framework_TestCase { + public function setUp() + { + global $class_loader; + $class_loader->unregister(); + } + + public function tearDown() + { + global $class_loader; + $class_loader->register(); + } + public function test_resolve_path() { $prefix = __DIR__ . '/'; -- cgit v1.2.1 From 9329b16ab13f3a4caf107df358c3c58bda2dcd8a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 3 Nov 2010 18:35:31 +0100 Subject: [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 --- tests/class_loader/class_loader_test.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/class_loader/class_loader_test.php') 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); -- cgit v1.2.1 From 1aef7eb20ee195c7f21d6c5b78653b7c43e669ec Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 9 Jan 2011 21:09:56 +0100 Subject: [task/acm-refactor] Cleaning up left over mentions of ACM and fixing tests. PHPBB3-9983 --- tests/class_loader/class_loader_test.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'tests/class_loader/class_loader_test.php') diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index c01278f914..cc6862dc70 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -2,13 +2,12 @@ /** * * @package testing -* @version $Id$ -* @copyright (c) 2008 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ -require_once __DIR__ . '/cache_mock.php'; +require_once __DIR__ . '/../mock/cache.php'; class phpbb_class_loader_test extends PHPUnit_Framework_TestCase { @@ -62,15 +61,7 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase public function test_resolve_cached() { $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]; - })); + $cache = new phpbb_mock_cache($cacheMap); $prefix = __DIR__ . '/'; $class_loader = new phpbb_class_loader($prefix, '.php', $cache); @@ -88,5 +79,8 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase $class_loader->resolve_path('phpbb_a_cached_name'), 'Class in a directory' ); + + $cacheMap['class_loader']['phpbb_dir_class_name'] = 'dir/class_name'; + $cache->check($this, $cacheMap); } } -- cgit v1.2.1