diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2011-01-27 18:26:58 -0500 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-02-12 14:44:53 +0100 |
commit | 8de411cc25e0a72dea858e247e7200df2fbccfea (patch) | |
tree | c45ab311fdb93441c93d4cb8fa70b5ee457b67a8 /tests/cache | |
parent | f50d74506a2334a83e03ae50c65a237d766c7d7e (diff) | |
download | forums-8de411cc25e0a72dea858e247e7200df2fbccfea.tar forums-8de411cc25e0a72dea858e247e7200df2fbccfea.tar.gz forums-8de411cc25e0a72dea858e247e7200df2fbccfea.tar.bz2 forums-8de411cc25e0a72dea858e247e7200df2fbccfea.tar.xz forums-8de411cc25e0a72dea858e247e7200df2fbccfea.zip |
[ticket/10013] Changed cache test to use tests/tmp/cache as cache directory
This is the first step of making the test suite use a single directory
for writing files to, this directory being tests/tmp.
The cache test, instead of tests/cache/tmp, now writes to tests/tmp/cache.
Also remove cache directory in setUp method, in case an earlier test run
did not complete successfully and the cache directory was not cleaned up.
Finally, this change makes the cache test take responsibility over the entire
contents of its cache directory.
PHPBB3-10013
Diffstat (limited to 'tests/cache')
-rw-r--r-- | tests/cache/cache_test.php | 40 | ||||
-rw-r--r-- | tests/cache/tmp/.gitkeep | 0 |
2 files changed, 36 insertions, 4 deletions
diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php index 2f11267cba..61908dbe31 100644 --- a/tests/cache/cache_test.php +++ b/tests/cache/cache_test.php @@ -11,21 +11,53 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_cache_test extends phpbb_test_case { + private $cache_dir; + + public function __construct() + { + $this->cache_dir = dirname(__FILE__) . '/../tmp/cache'; + } + + protected function setUp() + { + if (file_exists($this->cache_dir)) + { + // cache directory possibly left after aborted + // or failed run earlier + $this->remove_cache_dir(); + } + $this->create_cache_dir(); + } + protected function tearDown() { - $iterator = new DirectoryIterator(dirname(__FILE__) . '/tmp'); + if (file_exists($this->cache_dir)) + { + $this->remove_cache_dir(); + } + } + + private function create_cache_dir() + { + mkdir($this->cache_dir); + } + + private function remove_cache_dir() + { + $iterator = new DirectoryIterator($this->cache_dir); foreach ($iterator as $file) { - if (is_file(dirname(__FILE__) . '/tmp/' . $file) && $file != '.gitkeep') + if ($file != '.' && $file != '..') { - unlink(dirname(__FILE__) . '/tmp/' . $file); + unlink($this->cache_dir . '/' . $file); } } + rmdir($this->cache_dir); } public function test_cache_driver_file() { - $driver = new phpbb_cache_driver_file(dirname(__FILE__) . '/tmp/'); + $driver = new phpbb_cache_driver_file($this->cache_dir); $driver->put('test_key', 'test_value'); $driver->save(); diff --git a/tests/cache/tmp/.gitkeep b/tests/cache/tmp/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 --- a/tests/cache/tmp/.gitkeep +++ /dev/null |