3 namespace Friendica\Test\src\Core\Config;
5 use Friendica\Core\Config\JitConfiguration;
7 class JitConfigurationTest extends ConfigurationTest
9 public function getInstance()
11 return new JitConfiguration($this->configCache, $this->configModel);
15 * @dataProvider dataConfigLoad
17 public function testSetUp(array $data)
19 $this->configModel->shouldReceive('load')
21 ->andReturn(['config' => $data['config']])
24 parent::testSetUp($data);
28 * @dataProvider dataConfigLoad
30 public function testLoad(array $data, array $possibleCats, array $load)
32 $this->configModel->shouldReceive('isConnected')
34 ->times(count($load) + 1);
36 $this->configModel->shouldReceive('load')
38 ->andReturn(['config' => $data['config']])
41 foreach ($load as $loadCat) {
42 $this->configModel->shouldReceive('load')
44 ->andReturn([$loadCat => $data[$loadCat]])
48 parent::testLoad($data, $possibleCats, $load);
52 * @dataProvider dataDoubleLoad
54 public function testCacheLoadDouble(array $data1, array $data2, array $expect)
56 $this->configModel->shouldReceive('isConnected')
58 ->times(count($data1) + count($data2) + 1);
60 $this->configModel->shouldReceive('load')
62 ->andReturn(['config' => $data1['config']])
65 foreach ($data1 as $cat => $data) {
66 $this->configModel->shouldReceive('load')
68 ->andReturn([$cat => $data])
73 foreach ($data2 as $cat => $data) {
74 $this->configModel->shouldReceive('load')
76 ->andReturn([$cat => $data])
80 parent::testCacheLoadDouble($data1, $data2, $expect);
82 // Assert the expected categories
83 foreach ($data2 as $cat => $data) {
84 $this->assertConfig($cat, $expect[$cat]);
89 * @dataProvider dataTests
91 public function testSetGetWithDB($data)
93 $this->configModel->shouldReceive('isConnected')
97 $this->configModel->shouldReceive('load')->with('config')->andReturn(['config' => []])->once();
99 parent::testSetGetWithDB($data);
103 * @dataProvider dataTests
105 public function testGetWithRefresh($data)
107 $this->configModel->shouldReceive('isConnected')
111 // constructor loading
112 $this->configModel->shouldReceive('load')
114 ->andReturn(['config' => []])
117 // mocking one get without result
118 $this->configModel->shouldReceive('get')
123 // mocking the data get
124 $this->configModel->shouldReceive('get')
129 // mocking second get
130 $this->configModel->shouldReceive('get')
131 ->with('test', 'not')
135 parent::testGetWithRefresh($data);
138 public function testGetWrongWithoutDB()
140 $this->configModel->shouldReceive('isConnected')
144 parent::testGetWrongWithoutDB();
148 * @dataProvider dataTests
150 public function testDeleteWithoutDB($data)
152 $this->configModel->shouldReceive('isConnected')
156 parent::testDeleteWithoutDB($data);
159 public function testDeleteWithDB()
161 $this->configModel->shouldReceive('isConnected')
165 // constructor loading
166 $this->configModel->shouldReceive('load')
168 ->andReturn(['config' => []])
171 // mocking one get without result
172 $this->configModel->shouldReceive('get')
177 parent::testDeleteWithDB();