Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_cache_apcu_driver_test | |
0.00% |
0 / 20 |
|
0.00% |
0 / 4 |
72 | |
0.00% |
0 / 1 |
| getDataSet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setUpBeforeClass | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |||
| setUp | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_purge | |
0.00% |
0 / 5 |
|
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 | // Important: apc.enable_cli=1 must be in php.ini. |
| 15 | // http://forums.devshed.com/php-development-5/apc-problem-561290.html |
| 16 | // http://php.net/manual/en/apc.configuration.php |
| 17 | |
| 18 | require_once __DIR__ . '/common_test_case.php'; |
| 19 | |
| 20 | class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case |
| 21 | { |
| 22 | public function getDataSet() |
| 23 | { |
| 24 | return $this->createXMLDataSet(__DIR__ . '/fixtures/config.xml'); |
| 25 | } |
| 26 | |
| 27 | static public function setUpBeforeClass(): void |
| 28 | { |
| 29 | if (!extension_loaded('apcu')) |
| 30 | { |
| 31 | self::markTestSkipped('APCu extension is not loaded'); |
| 32 | } |
| 33 | |
| 34 | $php_ini = new \bantu\IniGetWrapper\IniGetWrapper; |
| 35 | |
| 36 | if (!$php_ini->getBool('apc.enabled')) |
| 37 | { |
| 38 | self::markTestSkipped('APCu is not enabled. Make sure apc.enabled=1 in php.ini'); |
| 39 | } |
| 40 | |
| 41 | if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli')) |
| 42 | { |
| 43 | self::markTestSkipped('APCu is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); |
| 44 | } |
| 45 | |
| 46 | parent::setUpBeforeClass(); |
| 47 | } |
| 48 | |
| 49 | protected function setUp(): void |
| 50 | { |
| 51 | global $phpbb_container, $phpbb_root_path; |
| 52 | |
| 53 | parent::setUp(); |
| 54 | |
| 55 | $phpbb_container = new phpbb_mock_container_builder(); |
| 56 | $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); |
| 57 | |
| 58 | $this->driver = new \phpbb\cache\driver\apcu; |
| 59 | |
| 60 | $this->driver->purge(); |
| 61 | } |
| 62 | |
| 63 | public function test_purge() |
| 64 | { |
| 65 | /* add a cache entry which does not match our key */ |
| 66 | $foreign_key = 'test_' . $this->driver->key_prefix . 'test'; |
| 67 | $this->assertSame(true, apcu_store($foreign_key, 0, 600)); |
| 68 | $this->assertSame(true, apcu_exists($foreign_key)); |
| 69 | |
| 70 | parent::test_purge(); |
| 71 | |
| 72 | $this->assertSame(true, apcu_exists($foreign_key)); |
| 73 | } |
| 74 | } |