]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Config/PreloadConfigurationTest.php
Add output for installerTest
[friendica.git] / tests / src / Core / Config / PreloadConfigurationTest.php
1 <?php
2
3 namespace Friendica\Test\src\Core\Config;
4
5 use Friendica\Core\Config\PreloadConfiguration;
6
7 class PreloadConfigurationTest extends ConfigurationTest
8 {
9         public function getInstance()
10         {
11                 return new PreloadConfiguration($this->configCache, $this->configModel);
12         }
13
14         /**
15          * @dataProvider dataConfigLoad
16          */
17         public function testSetUp(array $data)
18         {
19                 $this->configModel->shouldReceive('load')
20                                   ->andReturn($data)
21                                   ->once();
22
23                 parent::testSetUp($data);
24         }
25
26         /**
27          * @dataProvider dataConfigLoad
28          */
29         public function testLoad(array $data, array $possibleCats, array $load)
30         {
31                 $this->configModel->shouldReceive('isConnected')
32                                   ->andReturn(true)
33                                   ->once();
34
35                 $this->configModel->shouldReceive('load')
36                                   ->andReturn($data)
37                                   ->once();
38
39                 parent::testLoad($data, $possibleCats, $load);
40
41                 // Assert that every category is loaded everytime
42                 foreach ($data as $cat => $values) {
43                         $this->assertConfig($cat, $values);
44                 }
45         }
46
47         /**
48          * @dataProvider dataDoubleLoad
49          */
50         public function testCacheLoadDouble(array $data1, array $data2, array $expect)
51         {
52                 $this->configModel->shouldReceive('isConnected')
53                                   ->andReturn(true)
54                                   ->once();
55
56                 $this->configModel->shouldReceive('load')
57                                   ->andReturn($data1)
58                                   ->once();
59
60                 parent::testCacheLoadDouble($data1, $data2, $expect);
61
62                 // Assert that every category is loaded everytime and is NOT overwritten
63                 foreach ($data1 as $cat => $values) {
64                         $this->assertConfig($cat, $values);
65                 }
66         }
67
68         /**
69          * @dataProvider dataTests
70          */
71         public function testSetGetWithDB($data)
72         {
73                 $this->configModel->shouldReceive('isConnected')
74                                   ->andReturn(true)
75                                   ->times(2);
76
77                 $this->configModel->shouldReceive('load')->andReturn(['config' => []])->once();
78
79                 parent::testSetGetWithDB($data);
80         }
81
82         /**
83          * @dataProvider dataTests
84          */
85         public function testGetWithRefresh($data)
86         {
87                 $this->configModel->shouldReceive('isConnected')
88                                   ->andReturn(true)
89                                   ->times(2);
90
91                 // constructor loading
92                 $this->configModel->shouldReceive('load')
93                                   ->andReturn(['config' => []])
94                                   ->once();
95
96                 // mocking one get
97                 $this->configModel->shouldReceive('get')
98                                   ->with('test', 'it')
99                                   ->andReturn($data)
100                                   ->once();
101
102                 parent::testGetWithRefresh($data);
103         }
104
105
106         public function testGetWrongWithoutDB()
107         {
108                 $this->configModel->shouldReceive('isConnected')
109                                   ->andReturn(false)
110                                   ->times(2);
111
112                 parent::testGetWrongWithoutDB();
113         }
114
115         /**
116          * @dataProvider dataTests
117          */
118         public function testDeleteWithoutDB($data)
119         {
120                 $this->configModel->shouldReceive('isConnected')
121                                   ->andReturn(false)
122                                   ->times(2);
123
124                 parent::testDeleteWithoutDB($data);
125         }
126
127         public function testDeleteWithDB()
128         {
129                 $this->configModel->shouldReceive('isConnected')
130                                   ->andReturn(true)
131                                   ->times(5);
132
133                 // constructor loading
134                 $this->configModel->shouldReceive('load')
135                                   ->andReturn(['config' => []])
136                                   ->once();
137
138                 parent::testDeleteWithDB();
139         }
140 }