aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/migrator_tool_config_test.php
blob: 807399385c91cf15987ff02a777512b29c1de92a (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
78
79
80
81
82
83
84
85
86
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
{
	public function setup()
	{
		$this->config = new \phpbb\config\config(array());

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

		parent::setup();
	}

	public function test_add()
	{
		$this->tool->add('foo', 'bar');
		$this->assertEquals('bar', $this->config['foo']);
	}

	public function test_add_twice()
	{
		$this->tool->add('foo', 'bar');
		$this->assertEquals('bar', $this->config['foo']);

		$this->tool->add('foo', 'bar2');
		$this->assertEquals('bar', $this->config['foo']);
	}

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

		$this->tool->update('foo', 'bar2');
		$this->assertEquals('bar2', $this->config['foo']);
	}

	public function test_update_if_equals()
	{
		$this->config->set('foo', 'bar');

		$this->tool->update_if_equals('', 'foo', 'bar2');
		$this->assertEquals('bar', $this->config['foo']);

		$this->tool->update_if_equals('bar', 'foo', 'bar2');
		$this->assertEquals('bar2', $this->config['foo']);
	}

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

		$this->tool->remove('foo');
		$this->assertFalse(isset($this->config['foo']));
	}

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

		$this->tool->reverse('add', 'foo');
		$this->assertFalse(isset($this->config['foo']));
	}

	public function test_reverse_remove()
	{
		$this->config->delete('foo');

		$this->tool->reverse('remove', 'foo');
		$this->assertEquals('', $this->config['foo']);
	}

	public function test_reverse_update_if_equals()
	{
		$this->config->set('foo', 'bar');

		$this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
		$this->assertEquals('test', $this->config['foo']);
	}
}