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/cache | |
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/cache')
-rw-r--r-- | tests/cache/all_tests.php | 40 | ||||
-rw-r--r-- | tests/cache/cache_test.php | 39 |
2 files changed, 79 insertions, 0 deletions
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 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +if (!defined('PHPUnit_MAIN_METHOD')) +{ + define('PHPUnit_MAIN_METHOD', 'phpbb_request_all_tests::main'); +} + +require_once 'test_framework/framework.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; + +require_once 'cache/cache_test.php'; + +class phpbb_cache_all_tests +{ + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('phpBB Cache System'); + + $suite->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 @@ +<?php +/** +* +* @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'; + +class phpbb_cache_test extends phpbb_test_case +{ + protected function tearDown() + { + $iterator = new DirectoryIterator('cache/tmp'); + foreach ($iterator as $file) + { + if (is_file('cache/tmp/' . $file)) + { + unlink('cache/tmp/' . $file); + } + } + } + + public function test_acm_file() + { + $acm = new phpbb_cache_driver_file('cache/tmp/'); + $acm->put('test_key', 'test_value'); + $acm->save(); + + $this->assertEquals( + 'test_value', + $acm->get('test_key'), + 'File ACM put and get' + ); + } +} |