diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-05-04 10:12:41 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-05-04 10:13:04 +0200 |
commit | 292d0ab382563143082bd8809ec189d646a31e0e (patch) | |
tree | 422200896db845a4ac3668eafc87575f2423a760 /tests/cache/dummy_driver_test.php | |
parent | 232f71dae43df9794184961431aca81d0e4652da (diff) | |
download | forums-292d0ab382563143082bd8809ec189d646a31e0e.tar forums-292d0ab382563143082bd8809ec189d646a31e0e.tar.gz forums-292d0ab382563143082bd8809ec189d646a31e0e.tar.bz2 forums-292d0ab382563143082bd8809ec189d646a31e0e.tar.xz forums-292d0ab382563143082bd8809ec189d646a31e0e.zip |
[ticket/13782] Rename null driver test to dummy driver test
PHPBB3-13782
Diffstat (limited to 'tests/cache/dummy_driver_test.php')
-rw-r--r-- | tests/cache/dummy_driver_test.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/cache/dummy_driver_test.php b/tests/cache/dummy_driver_test.php new file mode 100644 index 0000000000..6cb6b73729 --- /dev/null +++ b/tests/cache/dummy_driver_test.php @@ -0,0 +1,77 @@ +<?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. +* +*/ + +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() + { + parent::setUp(); + + $this->driver = new \phpbb\cache\driver\dummy; + } + + public function test_get_put() + { + $this->assertSame(false, $this->driver->get('key')); + + $this->driver->put('key', 'value'); + + // null driver does not cache + $this->assertSame(false, $this->driver->get('key')); + } + + public function test_purge() + { + $this->assertNull($this->driver->purge()); + } + + public function test_destroy() + { + $this->assertNull($this->driver->destroy('foo')); + } + + public function test_cache_sql() + { + global $db, $cache, $phpbb_root_path, $phpEx; + $config = new phpbb\config\config(array()); + $db = $this->new_dbal(); + $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); + + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + $expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0); + $this->assertEquals($expected, $first_result); + + $sql = 'DELETE FROM phpbb_config'; + $result = $db->sql_query($sql); + + // As null cache driver does not actually cache, + // this should return no results + $sql = "SELECT * FROM phpbb_config + WHERE config_name = 'foo'"; + $result = $db->sql_query($sql, 300); + + $this->assertSame(false, $db->sql_fetchrow($result)); + + $db->sql_close(); + } +} |