aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-01-09 21:09:56 +0100
committerIgor Wiedler <igor@wiedler.ch>2011-01-09 23:49:44 +0100
commit1aef7eb20ee195c7f21d6c5b78653b7c43e669ec (patch)
treeac11043ba149791a225d587e7a61e34db75a04f6 /tests
parent9329b16ab13f3a4caf107df358c3c58bda2dcd8a (diff)
downloadforums-1aef7eb20ee195c7f21d6c5b78653b7c43e669ec.tar
forums-1aef7eb20ee195c7f21d6c5b78653b7c43e669ec.tar.gz
forums-1aef7eb20ee195c7f21d6c5b78653b7c43e669ec.tar.bz2
forums-1aef7eb20ee195c7f21d6c5b78653b7c43e669ec.tar.xz
forums-1aef7eb20ee195c7f21d6c5b78653b7c43e669ec.zip
[task/acm-refactor] Cleaning up left over mentions of ACM and fixing tests.
PHPBB3-9983
Diffstat (limited to 'tests')
-rw-r--r--tests/cache/all_tests.php40
-rw-r--r--tests/cache/cache_test.php24
-rw-r--r--tests/cache/tmp/.gitkeep0
-rw-r--r--tests/class_loader/class_loader_test.php18
-rw-r--r--tests/mock/cache.php (renamed from tests/class_loader/cache_mock.php)35
5 files changed, 43 insertions, 74 deletions
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 @@
-<?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
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
--- /dev/null
+++ b/tests/cache/tmp/.gitkeep
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);
}
}
diff --git a/tests/class_loader/cache_mock.php b/tests/mock/cache.php
index 73d1e64cf5..3bfb31f1be 100644
--- a/tests/class_loader/cache_mock.php
+++ b/tests/mock/cache.php
@@ -2,31 +2,44 @@
/**
*
* @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 '../phpBB/includes/cache/driver/interface.php';
-
-class phpbb_cache_mock implements phpbb_cache_driver_interface
+class phpbb_mock_cache implements phpbb_cache_driver_interface
{
- private $variables = array();
+ protected $data;
- function get($var_name)
+ public function __construct($data = array())
{
- if (isset($this->variables[$var_name]))
+ $this->data = $data;
+ }
+
+ public function get($var_name)
+ {
+ if (isset($this->data[$var_name]))
{
- return $this->variables[$var_name];
+ return $this->data[$var_name];
}
return false;
}
- function put($var_name, $value, $ttl = 0)
+ public function put($var_name, $var, $ttl = 0)
+ {
+ $this->data[$var_name] = $var;
+ }
+
+ public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
+ {
+ $test->assertTrue(isset($this->data[$var_name]));
+ $test->assertEquals($data, $this->data[$var_name]);
+ }
+
+ public function check(PHPUnit_Framework_Assert $test, $data)
{
- $this->variables[$var_name] = $value;
+ $test->assertEquals($data, $this->data);
}
function load()