3 * @copyright Copyright (C) 2010-2023, the Friendica project
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\Type\PreloadPConfig;
26 class PreloadPConfigTest extends PConfigTest
28 public function getInstance()
30 return new \Friendica\Core\PConfig\Type\PreloadPConfig($this->configCache, $this->configModel);
34 * @dataProvider dataConfigLoad
36 public function testLoad(int $uid, array $data, array $possibleCats, array $load)
38 $this->configModel->shouldReceive('isConnected')
42 $this->configModel->shouldReceive('load')
47 parent::testLoad($uid, $data, $possibleCats, $load);
49 // Assert that every category is loaded everytime
50 foreach ($data as $cat => $values) {
51 self::assertConfig($uid, $cat, $values);
56 * @dataProvider dataDoubleLoad
58 public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
60 $this->configModel->shouldReceive('isConnected')
64 $this->configModel->shouldReceive('load')
69 parent::testCacheLoadDouble($uid, $data1, $data2, $expect);
71 // Assert that every category is loaded everytime and is NOT overwritten
72 foreach ($data1 as $cat => $values) {
73 self::assertConfig($uid, $cat, $values);
78 * @dataProvider dataTests
80 public function testSetGetWithoutDB(int $uid, $data)
82 $this->configModel->shouldReceive('isConnected')
86 parent::testSetGetWithoutDB($uid, $data);
90 * @dataProvider dataTests
92 public function testSetGetWithDB(int $uid, $data)
94 $this->configModel->shouldReceive('isConnected')
98 $this->configModel->shouldReceive('load')
100 ->andReturn(['config' => []])
103 parent::testSetGetWithDB($uid, $data);
107 * @dataProvider dataTests
109 public function testGetWithRefresh(int $uid, $data)
111 $this->configModel->shouldReceive('isConnected')
115 // constructor loading
116 $this->configModel->shouldReceive('load')
118 ->andReturn(['config' => []])
122 $this->configModel->shouldReceive('get')
123 ->with($uid, 'test', 'it')
127 parent::testGetWithRefresh($uid, $data);
131 * @dataProvider dataTests
133 public function testDeleteWithoutDB(int $uid, $data)
135 $this->configModel->shouldReceive('isConnected')
139 parent::testDeleteWithoutDB($uid, $data);
142 public function testDeleteWithDB()
144 $this->configModel->shouldReceive('isConnected')
148 // constructor loading
149 $this->configModel->shouldReceive('load')
151 ->andReturn(['config' => []])
154 parent::testDeleteWithDB();