aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/migrator_tool_config_text_test.php
blob: b271c2d62ecbbdda9f70cf5cccc22976834ea096 (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
<?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_dbal_migrator_tool_config_text_test extends phpbb_database_test_case
{
	public function getDataSet()
	{
		return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_config_text.xml');
	}

	public function setup()
	{
		parent::setup();

		$this->db = $this->new_dbal();
		$this->config_text = new \phpbb\config\db_text($this->db, 'phpbb_config_text');

		$this->tool = new \phpbb\db\migration\tool\config_text($this->config_text);
	}

	public function test_add()
	{
		$this->tool->add('foo', 'bar');
		$this->assertEquals('bar', $this->config_text->get('foo'));
	}

	public function test_add_twice()
	{
		$this->tool->add('foo', 'bar');
		$this->assertEquals('bar', $this->config_text->get('foo'));

		$this->tool->add('foo', 'bar2');
		$this->assertEquals('bar', $this->config_text->get('foo'));
	}

	public function test_update()
	{
		$this->config_text->set('foo', 'bar');

		$this->tool->update('foo', 'bar2');
		$this->assertEquals('bar2', $this->config_text->get('foo'));
	}

	public function test_remove()
	{
		$this->config_text->set('foo', 'bar');

		$this->tool->remove('foo');
		$this->assertNull($this->config_text->get('foo'));
	}

	public function test_reverse_add()
	{
		$this->config_text->set('foo', 'bar');

		$this->tool->reverse('add', 'foo');
		$this->assertNull($this->config_text->get('foo'));
	}

	public function test_reverse_remove()
	{
		$this->tool->reverse('remove', 'foo');
		$this->assertSame('', $this->config_text->get('foo'));
	}
}