3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Core\Config;
24 use Friendica\Core\Config\JitConfig;
26 class JitConfigTest extends ConfigTest
28 public function getInstance()
30 return new JitConfig($this->configCache, $this->configModel);
34 * @dataProvider dataConfigLoad
36 public function testSetUp(array $data)
38 $this->configModel->shouldReceive('load')
40 ->andReturn(['config' => $data['config']])
43 parent::testSetUp($data);
47 * @dataProvider dataConfigLoad
49 public function testLoad(array $data, array $possibleCats, array $load)
51 $this->configModel->shouldReceive('isConnected')
53 ->times(count($load) + 1);
55 $this->configModel->shouldReceive('load')
57 ->andReturn(['config' => $data['config']])
60 foreach ($load as $loadCat) {
61 $this->configModel->shouldReceive('load')
63 ->andReturn([$loadCat => $data[$loadCat]])
67 parent::testLoad($data, $possibleCats, $load);
71 * @dataProvider dataDoubleLoad
73 public function testCacheLoadDouble(array $data1, array $data2, array $expect)
75 $this->configModel->shouldReceive('isConnected')
77 ->times(count($data1) + count($data2) + 1);
79 $this->configModel->shouldReceive('load')
81 ->andReturn(['config' => $data1['config']])
84 foreach ($data1 as $cat => $data) {
85 $this->configModel->shouldReceive('load')
87 ->andReturn([$cat => $data])
92 foreach ($data2 as $cat => $data) {
93 $this->configModel->shouldReceive('load')
95 ->andReturn([$cat => $data])
99 parent::testCacheLoadDouble($data1, $data2, $expect);
101 // Assert the expected categories
102 foreach ($data2 as $cat => $data) {
103 $this->assertConfig($cat, $expect[$cat]);
108 * @dataProvider dataTests
110 public function testSetGetWithDB($data)
112 $this->configModel->shouldReceive('isConnected')
116 $this->configModel->shouldReceive('load')->with('config')->andReturn(['config' => []])->once();
118 parent::testSetGetWithDB($data);
122 * @dataProvider dataTests
124 public function testGetWithRefresh($data)
126 $this->configModel->shouldReceive('isConnected')
130 // constructor loading
131 $this->configModel->shouldReceive('load')
133 ->andReturn(['config' => []])
136 // mocking one get without result
137 $this->configModel->shouldReceive('get')
142 // mocking the data get
143 $this->configModel->shouldReceive('get')
148 // mocking second get
149 $this->configModel->shouldReceive('get')
150 ->with('test', 'not')
154 parent::testGetWithRefresh($data);
157 public function testGetWrongWithoutDB()
159 $this->configModel->shouldReceive('isConnected')
163 parent::testGetWrongWithoutDB();
167 * @dataProvider dataTests
169 public function testDeleteWithoutDB($data)
171 $this->configModel->shouldReceive('isConnected')
175 parent::testDeleteWithoutDB($data);
178 public function testDeleteWithDB()
180 $this->configModel->shouldReceive('isConnected')
184 // constructor loading
185 $this->configModel->shouldReceive('load')
187 ->andReturn(['config' => []])
190 // mocking one get without result
191 $this->configModel->shouldReceive('get')
196 parent::testDeleteWithDB();