3 namespace Friendica\Test\src\Core\Config;
5 use Friendica\Core\Config\JitPConfiguration;
7 class JitPConfigurationTest extends PConfigurationTest
9 public function getInstance()
11 return new JitPConfiguration($this->configCache, $this->configModel);
15 * @dataProvider dataConfigLoad
17 public function testLoad(int $uid, array $data, array $possibleCats, array $load)
19 $this->configModel->shouldReceive('isConnected')
21 ->times(count($load));
23 foreach ($load as $loadCat) {
24 $this->configModel->shouldReceive('load')
25 ->with($uid, $loadCat)
26 ->andReturn([$loadCat => $data[$loadCat]])
30 parent::testLoad($uid, $data, $possibleCats, $load);
34 * @dataProvider dataDoubleLoad
36 public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
38 $this->configModel->shouldReceive('isConnected')
40 ->times(count($data1) + count($data2));
42 foreach ($data1 as $cat => $data) {
43 $this->configModel->shouldReceive('load')
45 ->andReturn([$cat => $data])
50 foreach ($data2 as $cat => $data) {
51 $this->configModel->shouldReceive('load')
53 ->andReturn([$cat => $data])
57 parent::testCacheLoadDouble($uid, $data1, $data2, $expect);
59 // Assert the expected categories
60 foreach ($data2 as $cat => $data) {
61 $this->assertConfig($uid, $cat, $expect[$cat]);
66 * @dataProvider dataTests
68 public function testSetGetWithoutDB(int $uid, $data)
70 $this->configModel->shouldReceive('isConnected')
74 parent::testSetGetWithoutDB($uid, $data);
78 * @dataProvider dataTests
80 public function testSetGetWithDB(int $uid, $data)
82 $this->configModel->shouldReceive('isConnected')
86 parent::testSetGetWithDB($uid, $data);
90 * @dataProvider dataTests
92 public function testGetWithRefresh(int $uid, $data)
94 $this->configModel->shouldReceive('isConnected')
98 // mocking one get without result
99 $this->configModel->shouldReceive('get')
100 ->with($uid, 'test', 'it')
104 // mocking the data get
105 $this->configModel->shouldReceive('get')
106 ->with($uid, 'test', 'it')
110 // mocking second get
111 $this->configModel->shouldReceive('get')
112 ->with($uid, 'test', 'not')
116 parent::testGetWithRefresh($uid, $data);
119 public function testGetWrongWithoutDB()
121 $this->configModel->shouldReceive('isConnected')
125 parent::testGetWrongWithoutDB();
129 * @dataProvider dataTests
131 public function testDeleteWithoutDB(int $uid, $data)
133 $this->configModel->shouldReceive('isConnected')
137 parent::testDeleteWithoutDB($uid, $data);
140 public function testDeleteWithDB()
142 $this->configModel->shouldReceive('isConnected')
146 // mocking one get without result
147 $this->configModel->shouldReceive('get')
148 ->with(0, 'test', 'it')
152 parent::testDeleteWithDB();