Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
phpbb_dbal_migrator_tool_config_text_test
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
8 / 8
8
100.00% covered (success)
100.00%
1 / 1
 getDataSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUp
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 test_add
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 test_add_twice
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 test_update
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 test_remove
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 test_reverse_add
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 test_reverse_remove
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
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
14class phpbb_dbal_migrator_tool_config_text_test extends phpbb_database_test_case
15{
16    protected $db;
17    protected $config_text;
18    protected $tool;
19
20    public function getDataSet()
21    {
22        return $this->createXMLDataSet(__DIR__.'/fixtures/migrator_config_text.xml');
23    }
24
25    protected function setUp(): void
26    {
27        parent::setUp();
28
29        $this->db = $this->new_dbal();
30        $this->config_text = new \phpbb\config\db_text($this->db, 'phpbb_config_text');
31
32        $this->tool = new \phpbb\db\migration\tool\config_text($this->config_text);
33    }
34
35    public function test_add()
36    {
37        $this->tool->add('foo', 'bar');
38        $this->assertEquals('bar', $this->config_text->get('foo'));
39    }
40
41    public function test_add_twice()
42    {
43        $this->tool->add('foo', 'bar');
44        $this->assertEquals('bar', $this->config_text->get('foo'));
45
46        $this->tool->add('foo', 'bar2');
47        $this->assertEquals('bar', $this->config_text->get('foo'));
48    }
49
50    public function test_update()
51    {
52        $this->config_text->set('foo', 'bar');
53
54        $this->tool->update('foo', 'bar2');
55        $this->assertEquals('bar2', $this->config_text->get('foo'));
56    }
57
58    public function test_remove()
59    {
60        $this->config_text->set('foo', 'bar');
61
62        $this->tool->remove('foo');
63        $this->assertNull($this->config_text->get('foo'));
64    }
65
66    public function test_reverse_add()
67    {
68        $this->config_text->set('foo', 'bar');
69
70        $this->tool->reverse('add', 'foo');
71        $this->assertNull($this->config_text->get('foo'));
72    }
73
74    public function test_reverse_remove()
75    {
76        $this->tool->reverse('remove', 'foo');
77        $this->assertSame('', $this->config_text->get('foo'));
78    }
79}