aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mock/cache.php
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-08 18:29:30 +0200
committerMaat <maat-pub@mageia.biz>2020-05-08 21:36:04 +0200
commit36bc1870f21fac04736a1049c1d5b8e127d729f4 (patch)
tree9d102331eeaf1ef3cd23e656320d7c08e65757ed /tests/mock/cache.php
parent8875d385d0579b451dac4d9bda465172b4f69ee0 (diff)
parent149375253685b3a38996f63015a74b7a0f53aa14 (diff)
downloadforums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar.gz
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar.bz2
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.tar.xz
forums-36bc1870f21fac04736a1049c1d5b8e127d729f4.zip
Merge remote-tracking branch 'upstream/prep-release-3.1.11'
Diffstat (limited to 'tests/mock/cache.php')
-rw-r--r--tests/mock/cache.php113
1 files changed, 82 insertions, 31 deletions
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index acf4288319..5fa3d28147 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -1,22 +1,23 @@
<?php
/**
*
-* @package testing
-* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
-class phpbb_mock_cache
+class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface
{
+ protected $data;
+
public function __construct($data = array())
{
$this->data = $data;
-
- if (!isset($this->data['_bots']))
- {
- $this->data['_bots'] = array();
- }
}
public function get($var_name)
@@ -34,24 +35,6 @@ class phpbb_mock_cache
$this->data[$var_name] = $var;
}
- public function destroy($var_name, $table = '')
- {
- if ($table)
- {
- throw new Exception('Destroying tables is not implemented yet');
- }
-
- unset($this->data[$var_name]);
- }
-
- /**
- * Obtain active bots
- */
- public function obtain_bots()
- {
- return $this->data['_bots'];
- }
-
/**
* Obtain list of word censors. We don't need to parse them here,
* that is tested elsewhere.
@@ -89,17 +72,32 @@ class phpbb_mock_cache
}
}
- public function set_bots($bots)
+ public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
{
- $this->data['_bots'] = $bots;
+ $test->assertTrue(isset($this->data[$var_name]));
+ $test->assertEquals($data, $this->data[$var_name]);
}
- public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
+ public function checkAssociativeVar(PHPUnit_Framework_Assert $test, $var_name, $data, $sort = true)
{
$test->assertTrue(isset($this->data[$var_name]));
+
+ if ($sort)
+ {
+ foreach ($this->data[$var_name] as &$content)
+ {
+ sort($content);
+ }
+ }
+
$test->assertEquals($data, $this->data[$var_name]);
}
+ public function checkVarUnset(PHPUnit_Framework_Assert $test, $var_name)
+ {
+ $test->assertFalse(isset($this->data[$var_name]));
+ }
+
public function check(PHPUnit_Framework_Assert $test, $data, $ignore_db_info = true)
{
$cache_data = $this->data;
@@ -116,5 +114,58 @@ class phpbb_mock_cache
$test->assertEquals($data, $cache_data);
}
-}
+ function load()
+ {
+ }
+ function unload()
+ {
+ }
+ function save()
+ {
+ }
+ function tidy()
+ {
+ }
+ function purge()
+ {
+ }
+ function destroy($var_name, $table = '')
+ {
+ unset($this->data[$var_name]);
+ }
+ public function _exists($var_name)
+ {
+ }
+ public function sql_load($query)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl)
+ {
+ return $query_result;
+ }
+ public function sql_exists($query_id)
+ {
+ }
+ public function sql_fetchrow($query_id)
+ {
+ }
+ public function sql_fetchfield($query_id, $field)
+ {
+ }
+ public function sql_rowseek($rownum, $query_id)
+ {
+ }
+ public function sql_freeresult($query_id)
+ {
+ }
+
+ public function obtain_bots()
+ {
+ return isset($this->data['_bots']) ? $this->data['_bots'] : array();
+ }
+}