3 namespace Friendica\Test\src\Core\PConfig;
5 use Friendica\Core\PConfig\PreloadPConfig;
6 use Friendica\Test\src\Core\PConfig\PConfigTest;
8 class PreloadPConfigTest extends PConfigTest
10 public function getInstance()
12 return new PreloadPConfig($this->configCache, $this->configModel);
16 * @dataProvider dataConfigLoad
18 public function testLoad(int $uid, array $data, array $possibleCats, array $load)
20 $this->configModel->shouldReceive('isConnected')
24 $this->configModel->shouldReceive('load')
29 parent::testLoad($uid, $data, $possibleCats, $load);
31 // Assert that every category is loaded everytime
32 foreach ($data as $cat => $values) {
33 $this->assertConfig($uid, $cat, $values);
38 * @dataProvider dataDoubleLoad
40 public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
42 $this->configModel->shouldReceive('isConnected')
46 $this->configModel->shouldReceive('load')
51 parent::testCacheLoadDouble($uid, $data1, $data2, $expect);
53 // Assert that every category is loaded everytime and is NOT overwritten
54 foreach ($data1 as $cat => $values) {
55 $this->assertConfig($uid, $cat, $values);
60 * @dataProvider dataTests
62 public function testSetGetWithoutDB(int $uid, $data)
64 $this->configModel->shouldReceive('isConnected')
68 parent::testSetGetWithoutDB($uid, $data);
72 * @dataProvider dataTests
74 public function testSetGetWithDB(int $uid, $data)
76 $this->configModel->shouldReceive('isConnected')
80 $this->configModel->shouldReceive('load')
82 ->andReturn(['config' => []])
85 parent::testSetGetWithDB($uid, $data);
89 * @dataProvider dataTests
91 public function testGetWithRefresh(int $uid, $data)
93 $this->configModel->shouldReceive('isConnected')
97 // constructor loading
98 $this->configModel->shouldReceive('load')
100 ->andReturn(['config' => []])
104 $this->configModel->shouldReceive('get')
105 ->with($uid, 'test', 'it')
109 parent::testGetWithRefresh($uid, $data);
113 * @dataProvider dataTests
115 public function testDeleteWithoutDB(int $uid, $data)
117 $this->configModel->shouldReceive('isConnected')
121 parent::testDeleteWithoutDB($uid, $data);
124 public function testDeleteWithDB()
126 $this->configModel->shouldReceive('isConnected')
130 // constructor loading
131 $this->configModel->shouldReceive('load')
133 ->andReturn(['config' => []])
136 parent::testDeleteWithDB();