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
51 public function testLoad(array $data, array $load)
53 $this->configModel->shouldReceive('isConnected')
57 $this->configModel->shouldReceive('load')
61 parent::testLoad($data, $load);
63 // Assert that every category is loaded everytime
64 foreach ($data as $cat => $values) {
65 self::assertConfig($cat, $values);
70 * @dataProvider dataDoubleLoad
75 public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
77 $this->configModel->shouldReceive('isConnected')
81 $this->configModel->shouldReceive('load')
85 parent::testCacheLoadDouble($data1, $data2);
87 // Assert that every category is loaded everytime and is NOT overwritten
88 foreach ($data1 as $cat => $values) {
89 self::assertConfig($cat, $values);
94 * @dataProvider dataTests
96 public function testSetGetWithDB($data)
98 $this->configModel->shouldReceive('isConnected')
102 $this->configModel->shouldReceive('load')->andReturn(['config' => []])->once();
104 parent::testSetGetWithDB($data);
108 * @dataProvider dataTests
110 public function testGetWithRefresh($data)
112 $this->configModel->shouldReceive('isConnected')
116 // constructor loading
117 $this->configModel->shouldReceive('load')
118 ->andReturn(['config' => []])
122 $this->configModel->shouldReceive('get')
127 parent::testGetWithRefresh($data);
131 public function testGetWrongWithoutDB()
133 $this->configModel->shouldReceive('isConnected')
137 parent::testGetWrongWithoutDB();
141 * @dataProvider dataTests
143 public function testDeleteWithoutDB($data)
145 $this->configModel->shouldReceive('isConnected')
149 parent::testDeleteWithoutDB($data);
152 public function testDeleteWithDB()
154 $this->configModel->shouldReceive('isConnected')
158 // constructor loading
159 $this->configModel->shouldReceive('load')
160 ->andReturn(['config' => []])
163 parent::testDeleteWithDB();