Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
29 / 29 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_dbal_migrator_tool_config_test | |
100.00% |
29 / 29 |
|
100.00% |
9 / 9 |
9 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_add | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| test_add_twice | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| test_update | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_update_if_equals | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| test_remove | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_reverse_add | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_reverse_remove | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| test_reverse_update_if_equals | |
100.00% |
3 / 3 |
|
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_dbal_migrator_tool_config_test extends phpbb_test_case |
| 15 | { |
| 16 | /** @var \phpbb\config\config */ |
| 17 | protected $config; |
| 18 | |
| 19 | /** @var \phpbb\db\migration\tool\tool_interface */ |
| 20 | protected $tool; |
| 21 | |
| 22 | protected function setUp(): void |
| 23 | { |
| 24 | $this->config = new \phpbb\config\config(array()); |
| 25 | |
| 26 | $this->tool = new \phpbb\db\migration\tool\config($this->config); |
| 27 | |
| 28 | parent::setup(); |
| 29 | } |
| 30 | |
| 31 | public function test_add() |
| 32 | { |
| 33 | $this->tool->add('foo', 'bar'); |
| 34 | $this->assertEquals('bar', $this->config['foo']); |
| 35 | } |
| 36 | |
| 37 | public function test_add_twice() |
| 38 | { |
| 39 | $this->tool->add('foo', 'bar'); |
| 40 | $this->assertEquals('bar', $this->config['foo']); |
| 41 | |
| 42 | $this->tool->add('foo', 'bar2'); |
| 43 | $this->assertEquals('bar', $this->config['foo']); |
| 44 | } |
| 45 | |
| 46 | public function test_update() |
| 47 | { |
| 48 | $this->config->set('foo', 'bar'); |
| 49 | |
| 50 | $this->tool->update('foo', 'bar2'); |
| 51 | $this->assertEquals('bar2', $this->config['foo']); |
| 52 | } |
| 53 | |
| 54 | public function test_update_if_equals() |
| 55 | { |
| 56 | $this->config->set('foo', 'bar'); |
| 57 | |
| 58 | $this->tool->update_if_equals('', 'foo', 'bar2'); |
| 59 | $this->assertEquals('bar', $this->config['foo']); |
| 60 | |
| 61 | $this->tool->update_if_equals('bar', 'foo', 'bar2'); |
| 62 | $this->assertEquals('bar2', $this->config['foo']); |
| 63 | } |
| 64 | |
| 65 | public function test_remove() |
| 66 | { |
| 67 | $this->config->set('foo', 'bar'); |
| 68 | |
| 69 | $this->tool->remove('foo'); |
| 70 | $this->assertFalse(isset($this->config['foo'])); |
| 71 | } |
| 72 | |
| 73 | public function test_reverse_add() |
| 74 | { |
| 75 | $this->config->set('foo', 'bar'); |
| 76 | |
| 77 | $this->tool->reverse('add', 'foo'); |
| 78 | $this->assertFalse(isset($this->config['foo'])); |
| 79 | } |
| 80 | |
| 81 | public function test_reverse_remove() |
| 82 | { |
| 83 | $this->config->delete('foo'); |
| 84 | |
| 85 | $this->tool->reverse('remove', 'foo'); |
| 86 | $this->assertEquals('', $this->config['foo']); |
| 87 | } |
| 88 | |
| 89 | public function test_reverse_update_if_equals() |
| 90 | { |
| 91 | $this->config->set('foo', 'bar'); |
| 92 | |
| 93 | $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar'); |
| 94 | $this->assertEquals('test', $this->config['foo']); |
| 95 | } |
| 96 | } |