aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cache
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2020-05-09 01:15:08 +0200
committerMaat <maat-pub@mageia.biz>2020-05-09 01:15:08 +0200
commit6985226b17e8a0ef0a720bf1d12fe0c216e13dab (patch)
tree116d2565ac02c40abe0548863c6badf8ec3e1d1e /tests/cache
parent8ea437e30605e0f66b5220bf904a61d7c1d11ddd (diff)
parent8d00784dfe2c8bcb10843ff70b4cfa998d703285 (diff)
downloadforums-master.tar
forums-master.tar.gz
forums-master.tar.bz2
forums-master.tar.xz
forums-master.zip
Merge remote-tracking branch 'upstream/prep-release-3.3.0'HEADmaster
Diffstat (limited to 'tests/cache')
-rw-r--r--tests/cache/apc_driver_test.php57
-rw-r--r--tests/cache/apcu_driver_test.php5
-rw-r--r--tests/cache/cache_memory_test.php2
-rw-r--r--tests/cache/common_test_case.php3
-rw-r--r--tests/cache/dummy_driver_test.php4
-rw-r--r--tests/cache/file_driver_test.php12
-rw-r--r--tests/cache/memcached_test.php65
-rw-r--r--tests/cache/redis_driver_test.php11
8 files changed, 85 insertions, 74 deletions
diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php
deleted file mode 100644
index 706f274448..0000000000
--- a/tests/cache/apc_driver_test.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
-*
-* 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.
-*
-*/
-
-// Important: apc.enable_cli=1 must be in php.ini.
-// http://forums.devshed.com/php-development-5/apc-problem-561290.html
-// http://php.net/manual/en/apc.configuration.php
-
-require_once dirname(__FILE__) . '/common_test_case.php';
-
-class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case
-{
- protected static $config;
- protected $driver;
-
- public function getDataSet()
- {
- return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
- }
-
- static public function setUpBeforeClass()
- {
- if (!extension_loaded('apc'))
- {
- self::markTestSkipped('APC extension is not loaded');
- }
-
- $php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
-
- if (!$php_ini->getBool('apc.enabled'))
- {
- self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini');
- }
-
- if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli'))
- {
- self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
- }
- }
-
- protected function setUp()
- {
- parent::setUp();
-
- $this->driver = new \phpbb\cache\driver\apc;
- $this->driver->purge();
- }
-}
diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php
index 57f640c313..34bcf8f844 100644
--- a/tests/cache/apcu_driver_test.php
+++ b/tests/cache/apcu_driver_test.php
@@ -20,7 +20,6 @@ require_once dirname(__FILE__) . '/common_test_case.php';
class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case
{
protected static $config;
- protected $driver;
public function getDataSet()
{
@@ -45,9 +44,11 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case
{
self::markTestSkipped('APCu is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
}
+
+ parent::setUpBeforeClass();
}
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_container, $phpbb_root_path;
diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php
index ba1010bcf3..b3d19f1782 100644
--- a/tests/cache/cache_memory_test.php
+++ b/tests/cache/cache_memory_test.php
@@ -23,7 +23,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/cache_memory.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
global $db;
parent::setUp();
diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php
index ee0649a755..64273c250a 100644
--- a/tests/cache/common_test_case.php
+++ b/tests/cache/common_test_case.php
@@ -13,6 +13,9 @@
abstract class phpbb_cache_common_test_case extends phpbb_database_test_case
{
+ /** @var \phpbb\cache\driver\driver_interface */
+ protected $driver;
+
public function test_get_put_exists()
{
$this->assertFalse($this->driver->_exists('test_key'));
diff --git a/tests/cache/dummy_driver_test.php b/tests/cache/dummy_driver_test.php
index 6cb6b73729..6802e120ab 100644
--- a/tests/cache/dummy_driver_test.php
+++ b/tests/cache/dummy_driver_test.php
@@ -13,14 +13,12 @@
class phpbb_cache_dummy_driver_test extends phpbb_database_test_case
{
- protected $driver;
-
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php
index 471316847d..37973edba3 100644
--- a/tests/cache/file_driver_test.php
+++ b/tests/cache/file_driver_test.php
@@ -16,22 +16,18 @@ require_once dirname(__FILE__) . '/common_test_case.php';
class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
{
private $cache_dir;
- protected $driver;
-
- public function __construct()
- {
- $this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
- }
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
+ $this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
+
if (file_exists($this->cache_dir))
{
// cache directory possibly left after aborted
@@ -43,7 +39,7 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
$this->driver = new \phpbb\cache\driver\file($this->cache_dir);
}
- protected function tearDown()
+ protected function tearDown(): void
{
if (file_exists($this->cache_dir))
{
diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php
new file mode 100644
index 0000000000..650b72ea18
--- /dev/null
+++ b/tests/cache/memcached_test.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ *
+ * 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.
+ *
+ */
+
+require_once dirname(__FILE__) . '/common_test_case.php';
+
+class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case
+{
+ protected static $config;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ static public function setUpBeforeClass()
+ {
+ if (!extension_loaded('memcached'))
+ {
+ self::markTestSkipped('memcached extension is not loaded');
+ }
+
+ $config = phpbb_test_case_helpers::get_test_config();
+ if (isset($config['memcached_host']) || isset($config['memcached_port']))
+ {
+ $host = isset($config['memcached_host']) ? $config['memcached_host'] : 'localhost';
+ $port = isset($config['memcached_port']) ? $config['memcached_port'] : 11211;
+ self::$config = array('host' => $host, 'port' => $port);
+ }
+ else
+ {
+ self::markTestSkipped('Test memcached host/port is not specified');
+ }
+
+ $memcached = new \Memcached();
+ $memcached->addServer(self::$config['host'], self::$config['port']);
+ if (empty($memcached->getStats()))
+ {
+ self::markTestSkipped('Test memcached server is not available');
+ }
+
+ parent::setUpBeforeClass();
+ }
+
+ protected function setUp(): void
+ {
+ global $phpbb_root_path, $phpbb_container;
+
+ parent::setUp();
+
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
+ $this->driver = new \phpbb\cache\driver\memcached(self::$config['host'] . '/' . self::$config['port']);
+ $this->driver->purge();
+ }
+}
diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php
index 387e6ca855..a2288cf9a8 100644
--- a/tests/cache/redis_driver_test.php
+++ b/tests/cache/redis_driver_test.php
@@ -13,10 +13,9 @@
require_once dirname(__FILE__) . '/common_test_case.php';
-class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case
+class phpbb_cache_redis_driver_test extends \phpbb_cache_common_test_case
{
protected static $config;
- protected $driver;
public function getDataSet()
{
@@ -41,12 +40,18 @@ class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case
{
self::markTestSkipped('Test redis host/port is not specified');
}
+
+ parent::setUpBeforeClass();
}
- protected function setUp()
+ protected function setUp(): void
{
+ global $phpbb_root_path, $phpbb_container;
+
parent::setUp();
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
$this->driver = new \phpbb\cache\driver\redis(self::$config['host'], self::$config['port']);
$this->driver->purge();
}