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\PConfig;
24 use Friendica\Core\PConfig\PreloadPConfig;
25 use Friendica\Test\src\Core\PConfig\PConfigTest;
27 class PreloadPConfigTest extends PConfigTest
29 public function getInstance()
31 return new PreloadPConfig($this->configCache, $this->configModel);
35 * @dataProvider dataConfigLoad
37 public function testLoad(int $uid, array $data, array $possibleCats, array $load)
39 $this->configModel->shouldReceive('isConnected')
43 $this->configModel->shouldReceive('load')
48 parent::testLoad($uid, $data, $possibleCats, $load);
50 // Assert that every category is loaded everytime
51 foreach ($data as $cat => $values) {
52 self::assertConfig($uid, $cat, $values);
57 * @dataProvider dataDoubleLoad
59 public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
61 $this->configModel->shouldReceive('isConnected')
65 $this->configModel->shouldReceive('load')
70 parent::testCacheLoadDouble($uid, $data1, $data2, $expect);
72 // Assert that every category is loaded everytime and is NOT overwritten
73 foreach ($data1 as $cat => $values) {
74 self::assertConfig($uid, $cat, $values);
79 * @dataProvider dataTests
81 public function testSetGetWithoutDB(int $uid, $data)
83 $this->configModel->shouldReceive('isConnected')
87 parent::testSetGetWithoutDB($uid, $data);
91 * @dataProvider dataTests
93 public function testSetGetWithDB(int $uid, $data)
95 $this->configModel->shouldReceive('isConnected')
99 $this->configModel->shouldReceive('load')
101 ->andReturn(['config' => []])
104 parent::testSetGetWithDB($uid, $data);
108 * @dataProvider dataTests
110 public function testGetWithRefresh(int $uid, $data)
112 $this->configModel->shouldReceive('isConnected')
116 // constructor loading
117 $this->configModel->shouldReceive('load')
119 ->andReturn(['config' => []])
123 $this->configModel->shouldReceive('get')
124 ->with($uid, 'test', 'it')
128 parent::testGetWithRefresh($uid, $data);
132 * @dataProvider dataTests
134 public function testDeleteWithoutDB(int $uid, $data)
136 $this->configModel->shouldReceive('isConnected')
140 parent::testDeleteWithoutDB($uid, $data);
143 public function testDeleteWithDB()
145 $this->configModel->shouldReceive('isConnected')
149 // constructor loading
150 $this->configModel->shouldReceive('load')
152 ->andReturn(['config' => []])
155 parent::testDeleteWithDB();