From ebac54aa9e705e99a562d2fe2c0f57bc6af8dd32 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 30 Dec 2018 11:36:08 +0100 Subject: [ticket/14948] Adjust calls for twig and phpunit updates PHPBB3-14948 --- tests/cache/apc_driver_test.php | 3 +-- tests/cache/apcu_driver_test.php | 5 +++-- tests/cache/cache_memory_test.php | 2 +- tests/cache/common_test_case.php | 3 +++ tests/cache/dummy_driver_test.php | 4 +--- tests/cache/file_driver_test.php | 12 ++++-------- tests/cache/redis_driver_test.php | 11 ++++++++--- 7 files changed, 21 insertions(+), 19 deletions(-) (limited to 'tests/cache') diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index 706f274448..276cbeb3e1 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -20,7 +20,6 @@ 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() { @@ -47,7 +46,7 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case } } - protected function setUp() + protected function setUp(): void { parent::setUp(); 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/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(); } -- cgit v1.2.1 From 25ae4fa355c0372c016ae9e4ff1ea16dba6588c7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Oct 2019 22:41:15 +0200 Subject: [ticket/15922] Remove driver for discontinued APC cache PHPBB3-15922 --- tests/cache/apc_driver_test.php | 56 ----------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 tests/cache/apc_driver_test.php (limited to 'tests/cache') diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php deleted file mode 100644 index 276cbeb3e1..0000000000 --- a/tests/cache/apc_driver_test.php +++ /dev/null @@ -1,56 +0,0 @@ - -* @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; - - 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(): void - { - parent::setUp(); - - $this->driver = new \phpbb\cache\driver\apc; - $this->driver->purge(); - } -} -- cgit v1.2.1 From fd7524858c9c178603cc3bb7440bcbad58c9096a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 25 Nov 2019 20:10:12 +0100 Subject: [ticket/16223] Add test for memcached driver PHPBB3-16223 --- tests/cache/memcached_test.php | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/cache/memcached_test.php (limited to 'tests/cache') diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php new file mode 100644 index 0000000000..2c63ed6bcb --- /dev/null +++ b/tests/cache/memcached_test.php @@ -0,0 +1,46 @@ + + * @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'); + } + + 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(); + $this->driver->purge(); + } +} -- cgit v1.2.1 From c7d47e34e82128399e1b20b9f80a85f46c4cfd75 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 25 Nov 2019 21:27:43 +0100 Subject: [ticket/16223] Ensure memcached tests are only run when available PHPBB3-16223 --- tests/cache/memcached_test.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests/cache') diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php index 2c63ed6bcb..a29f0040cf 100644 --- a/tests/cache/memcached_test.php +++ b/tests/cache/memcached_test.php @@ -29,6 +29,25 @@ class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case 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(); } @@ -40,7 +59,7 @@ class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case $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(); + $this->driver = new \phpbb\cache\driver\memcached(self::$config['host'], self::$config['port']); $this->driver->purge(); } } -- cgit v1.2.1 From 380b7d0a98f81d241208034bb76b1468485ea996 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 25 Nov 2019 22:16:41 +0100 Subject: [ticket/16223] Use constructor arguments instead of func_get_args() PHPBB3-16223 --- tests/cache/memcached_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/cache') diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php index a29f0040cf..650b72ea18 100644 --- a/tests/cache/memcached_test.php +++ b/tests/cache/memcached_test.php @@ -59,7 +59,7 @@ class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case $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 = new \phpbb\cache\driver\memcached(self::$config['host'] . '/' . self::$config['port']); $this->driver->purge(); } } -- cgit v1.2.1