aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cache/null_driver_test.php
blob: b9f96732f541ea46222337e9afafd43efafe648b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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_null_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\null;
	}

	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();
	}
}