Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_cache_memcached_driver_test | |
0.00% |
0 / 20 |
|
0.00% |
0 / 3 |
90 | |
0.00% |
0 / 1 |
| getDataSet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setUpBeforeClass | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
56 | |||
| setUp | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/common_test_case.php'; |
| 15 | |
| 16 | class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case |
| 17 | { |
| 18 | protected static $config; |
| 19 | |
| 20 | public function getDataSet() |
| 21 | { |
| 22 | return $this->createXMLDataSet(__DIR__ . '/fixtures/config.xml'); |
| 23 | } |
| 24 | |
| 25 | static public function setUpBeforeClass(): void |
| 26 | { |
| 27 | if (!extension_loaded('memcached')) |
| 28 | { |
| 29 | self::markTestSkipped('memcached extension is not loaded'); |
| 30 | } |
| 31 | |
| 32 | $config = phpbb_test_case_helpers::get_test_config(); |
| 33 | if (isset($config['memcached_host']) || isset($config['memcached_port'])) |
| 34 | { |
| 35 | $host = isset($config['memcached_host']) ? $config['memcached_host'] : 'localhost'; |
| 36 | $port = isset($config['memcached_port']) ? $config['memcached_port'] : 11211; |
| 37 | self::$config = array('host' => $host, 'port' => $port); |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | self::markTestSkipped('Test memcached host/port is not specified'); |
| 42 | } |
| 43 | |
| 44 | $memcached = new \Memcached(); |
| 45 | $memcached->addServer(self::$config['host'], self::$config['port']); |
| 46 | if (empty($memcached->getStats())) |
| 47 | { |
| 48 | self::markTestSkipped('Test memcached server is not available'); |
| 49 | } |
| 50 | |
| 51 | parent::setUpBeforeClass(); |
| 52 | } |
| 53 | |
| 54 | protected function setUp(): void |
| 55 | { |
| 56 | global $phpbb_root_path, $phpbb_container; |
| 57 | |
| 58 | parent::setUp(); |
| 59 | |
| 60 | $phpbb_container = new phpbb_mock_container_builder(); |
| 61 | $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); |
| 62 | $this->driver = new \phpbb\cache\driver\memcached(self::$config['host'] . '/' . self::$config['port']); |
| 63 | $this->driver->purge(); |
| 64 | } |
| 65 | } |