3 namespace Friendica\Test\src\Core\PConfig;
5 use Friendica\Core\PConfig\JitPConfig;
6 use Friendica\Test\src\Core\PConfig\PConfigTest;
8 class JitPConfigTest extends PConfigTest
10 public function getInstance()
12 return new JitPConfig($this->configCache, $this->configModel);
16 * @dataProvider dataConfigLoad
18 public function testLoad(int $uid, array $data, array $possibleCats, array $load)
20 $this->configModel->shouldReceive('isConnected')
22 ->times(count($load));
24 foreach ($load as $loadCat) {
25 $this->configModel->shouldReceive('load')
26 ->with($uid, $loadCat)
27 ->andReturn([$loadCat => $data[$loadCat]])
31 parent::testLoad($uid, $data, $possibleCats, $load);
35 * @dataProvider dataDoubleLoad
37 public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
39 $this->configModel->shouldReceive('isConnected')
41 ->times(count($data1) + count($data2));
43 foreach ($data1 as $cat => $data) {
44 $this->configModel->shouldReceive('load')
46 ->andReturn([$cat => $data])
51 foreach ($data2 as $cat => $data) {
52 $this->configModel->shouldReceive('load')
54 ->andReturn([$cat => $data])
58 parent::testCacheLoadDouble($uid, $data1, $data2, $expect);
60 // Assert the expected categories
61 foreach ($data2 as $cat => $data) {
62 $this->assertConfig($uid, $cat, $expect[$cat]);
67 * @dataProvider dataTests
69 public function testSetGetWithoutDB(int $uid, $data)
71 $this->configModel->shouldReceive('isConnected')
75 parent::testSetGetWithoutDB($uid, $data);
79 * @dataProvider dataTests
81 public function testSetGetWithDB(int $uid, $data)
83 $this->configModel->shouldReceive('isConnected')
87 parent::testSetGetWithDB($uid, $data);
91 * @dataProvider dataTests
93 public function testGetWithRefresh(int $uid, $data)
95 $this->configModel->shouldReceive('isConnected')
99 // mocking one get without result
100 $this->configModel->shouldReceive('get')
101 ->with($uid, 'test', 'it')
105 // mocking the data get
106 $this->configModel->shouldReceive('get')
107 ->with($uid, 'test', 'it')
111 // mocking second get
112 $this->configModel->shouldReceive('get')
113 ->with($uid, 'test', 'not')
117 parent::testGetWithRefresh($uid, $data);
121 * @dataProvider dataTests
123 public function testDeleteWithoutDB(int $uid, $data)
125 $this->configModel->shouldReceive('isConnected')
129 parent::testDeleteWithoutDB($uid, $data);
132 public function testDeleteWithDB()
134 $this->configModel->shouldReceive('isConnected')
138 // mocking one get without result
139 $this->configModel->shouldReceive('get')
140 ->with(42, 'test', 'it')
144 parent::testDeleteWithDB();