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/cache/all_tests.php | 40 ++++++++++++++++++++++++++++++++++++++++ tests/cache/cache_test.php | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/cache/all_tests.php create mode 100644 tests/cache/cache_test.php (limited to 'tests/cache') diff --git a/tests/cache/all_tests.php b/tests/cache/all_tests.php new file mode 100644 index 0000000000..829d496e5d --- /dev/null +++ b/tests/cache/all_tests.php @@ -0,0 +1,40 @@ +addTestSuite('phpbb_cache_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_cache_all_tests::main') +{ + phpbb_cache_all_tests::main(); +} diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php new file mode 100644 index 0000000000..220fddfd25 --- /dev/null +++ b/tests/cache/cache_test.php @@ -0,0 +1,39 @@ +put('test_key', 'test_value'); + $acm->save(); + + $this->assertEquals( + 'test_value', + $acm->get('test_key'), + 'File ACM put and get' + ); + } +} -- 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/cache/all_tests.php | 40 ---------------------------------------- tests/cache/cache_test.php | 24 +++++++++++++----------- tests/cache/tmp/.gitkeep | 0 3 files changed, 13 insertions(+), 51 deletions(-) delete mode 100644 tests/cache/all_tests.php create mode 100644 tests/cache/tmp/.gitkeep (limited to 'tests/cache') diff --git a/tests/cache/all_tests.php b/tests/cache/all_tests.php deleted file mode 100644 index 829d496e5d..0000000000 --- a/tests/cache/all_tests.php +++ /dev/null @@ -1,40 +0,0 @@ -addTestSuite('phpbb_cache_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_cache_all_tests::main') -{ - phpbb_cache_all_tests::main(); -} diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php index 220fddfd25..463095f129 100644 --- a/tests/cache/cache_test.php +++ b/tests/cache/cache_test.php @@ -2,37 +2,39 @@ /** * * @package testing -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ -require_once 'test_framework/framework.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_cache_test extends phpbb_test_case { protected function tearDown() { - $iterator = new DirectoryIterator('cache/tmp'); + $iterator = new DirectoryIterator(__DIR__ . '/tmp'); foreach ($iterator as $file) { - if (is_file('cache/tmp/' . $file)) + if (is_file(__DIR__ . '/tmp/' . $file) && $file != '.gitkeep') { - unlink('cache/tmp/' . $file); + unlink(__DIR__ . '/tmp/' . $file); } } } - public function test_acm_file() + public function test_cache_driver_file() { - $acm = new phpbb_cache_driver_file('cache/tmp/'); - $acm->put('test_key', 'test_value'); - $acm->save(); - + global $phpEx; + $phpEx = 'txt'; // do not store files as .php + + $driver = new phpbb_cache_driver_file(__DIR__ . '/tmp/'); + $driver->put('test_key', 'test_value'); + $driver->save(); + $this->assertEquals( 'test_value', - $acm->get('test_key'), + $driver->get('test_key'), 'File ACM put and get' ); } diff --git a/tests/cache/tmp/.gitkeep b/tests/cache/tmp/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.1