Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_cache_dummy_driver_test | |
100.00% |
26 / 26 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| getDataSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setUp | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| test_get_put | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_purge | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| test_destroy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| test_cache_sql | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
1 | |||
| 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 | class phpbb_cache_dummy_driver_test extends phpbb_database_test_case |
| 15 | { |
| 16 | protected $driver; |
| 17 | |
| 18 | public function getDataSet() |
| 19 | { |
| 20 | return $this->createXMLDataSet(__DIR__ . '/fixtures/config.xml'); |
| 21 | } |
| 22 | |
| 23 | protected function setUp(): void |
| 24 | { |
| 25 | parent::setUp(); |
| 26 | |
| 27 | $this->driver = new \phpbb\cache\driver\dummy; |
| 28 | } |
| 29 | |
| 30 | public function test_get_put() |
| 31 | { |
| 32 | $this->assertSame(false, $this->driver->get('key')); |
| 33 | |
| 34 | $this->driver->put('key', 'value'); |
| 35 | |
| 36 | // null driver does not cache |
| 37 | $this->assertSame(false, $this->driver->get('key')); |
| 38 | } |
| 39 | |
| 40 | public function test_purge() |
| 41 | { |
| 42 | $this->assertNull($this->driver->purge()); |
| 43 | } |
| 44 | |
| 45 | public function test_destroy() |
| 46 | { |
| 47 | $this->assertNull($this->driver->destroy('foo')); |
| 48 | } |
| 49 | |
| 50 | public function test_cache_sql() |
| 51 | { |
| 52 | global $db, $cache, $phpbb_root_path, $phpEx; |
| 53 | $config = new phpbb\config\config(array()); |
| 54 | $db = $this->new_dbal(); |
| 55 | $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); |
| 56 | $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_dispatcher, $phpbb_root_path, $phpEx); |
| 57 | |
| 58 | $sql = "SELECT * FROM phpbb_config |
| 59 | WHERE config_name = 'foo'"; |
| 60 | $result = $db->sql_query($sql, 300); |
| 61 | $first_result = $db->sql_fetchrow($result); |
| 62 | $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); |
| 63 | $this->assertEquals($expected, $first_result); |
| 64 | |
| 65 | $sql = 'DELETE FROM phpbb_config'; |
| 66 | $db->sql_query($sql); |
| 67 | |
| 68 | // As null cache driver does not actually cache, |
| 69 | // this should return no results |
| 70 | $sql = "SELECT * FROM phpbb_config |
| 71 | WHERE config_name = 'foo'"; |
| 72 | $result = $db->sql_query($sql, 300); |
| 73 | |
| 74 | $this->assertSame(false, $db->sql_fetchrow($result)); |
| 75 | |
| 76 | $db->sql_close(); |
| 77 | } |
| 78 | } |