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\PreloadConfig;
26 class PreloadConfigTest extends ConfigTest
28 public function getInstance()
30 return new PreloadConfig($this->configCache, $this->configModel);
34 * @dataProvider dataConfigLoad
36 public function testSetUp(array $data)
38 $this->configModel->shouldReceive('load')
42 parent::testSetUp($data);
46 * @dataProvider dataConfigLoad
48 public function testLoad(array $data, array $possibleCats, array $load)
50 $this->configModel->shouldReceive('isConnected')
54 $this->configModel->shouldReceive('load')
58 parent::testLoad($data, $possibleCats, $load);
60 // Assert that every category is loaded everytime
61 foreach ($data as $cat => $values) {
62 $this->assertConfig($cat, $values);
67 * @dataProvider dataDoubleLoad
69 public function testCacheLoadDouble(array $data1, array $data2, array $expect)
71 $this->configModel->shouldReceive('isConnected')
75 $this->configModel->shouldReceive('load')
79 parent::testCacheLoadDouble($data1, $data2, $expect);
81 // Assert that every category is loaded everytime and is NOT overwritten
82 foreach ($data1 as $cat => $values) {
83 $this->assertConfig($cat, $values);
88 * @dataProvider dataTests
90 public function testSetGetWithDB($data)
92 $this->configModel->shouldReceive('isConnected')
96 $this->configModel->shouldReceive('load')->andReturn(['config' => []])->once();
98 parent::testSetGetWithDB($data);
102 * @dataProvider dataTests
104 public function testGetWithRefresh($data)
106 $this->configModel->shouldReceive('isConnected')
110 // constructor loading
111 $this->configModel->shouldReceive('load')
112 ->andReturn(['config' => []])
116 $this->configModel->shouldReceive('get')
121 parent::testGetWithRefresh($data);
125 public function testGetWrongWithoutDB()
127 $this->configModel->shouldReceive('isConnected')
131 parent::testGetWrongWithoutDB();
135 * @dataProvider dataTests
137 public function testDeleteWithoutDB($data)
139 $this->configModel->shouldReceive('isConnected')
143 parent::testDeleteWithoutDB($data);
146 public function testDeleteWithDB()
148 $this->configModel->shouldReceive('isConnected')
152 // constructor loading
153 $this->configModel->shouldReceive('load')
154 ->andReturn(['config' => []])
157 parent::testDeleteWithDB();