5
5
*/
6
6
namespace Magento \MagentoCloud \Test \Unit \Config \Environment ;
7
7
8
- use Magento \MagentoCloud \Config \Environment ;
9
8
use Magento \MagentoCloud \Config \Environment \Reader ;
10
9
use Magento \MagentoCloud \Filesystem \ConfigFileList ;
11
10
use Magento \MagentoCloud \Filesystem \Driver \File ;
12
- use Magento \MagentoCloud \Filesystem \SystemList ;
13
11
use phpmock \phpunit \PHPMock ;
14
12
use PHPUnit \Framework \MockObject \MockObject ;
15
13
use PHPUnit \Framework \TestCase ;
@@ -21,16 +19,6 @@ class ReaderTest extends TestCase
21
19
{
22
20
use PHPMock;
23
21
24
- /**
25
- * @var SystemList|MockObject
26
- */
27
- private $ systemListMock ;
28
-
29
- /**
30
- * @var Environment|MockObject
31
- */
32
- private $ environmentMock ;
33
-
34
22
/**
35
23
* @var ConfigFileList|MockObject
36
24
*/
@@ -57,14 +45,10 @@ protected function setUp()
57
45
self ::defineFunctionMock ('Magento\MagentoCloud\Filesystem\Driver ' , 'file_get_contents ' );
58
46
self ::defineFunctionMock ('Magento\MagentoCloud\Filesystem\Driver ' , 'file_exists ' );
59
47
60
- $ this ->systemListMock = $ this ->createMock (SystemList::class);
61
- $ this ->environmentMock = $ this ->createMock (Environment::class);
62
48
$ this ->configFileListMock = $ this ->createMock (ConfigFileList::class);
63
49
$ this ->fileMock = $ this ->createPartialMock (File::class, []);
64
50
65
51
$ this ->reader = new Reader (
66
- $ this ->systemListMock ,
67
- $ this ->environmentMock ,
68
52
$ this ->configFileListMock ,
69
53
$ this ->fileMock
70
54
);
@@ -77,98 +61,18 @@ public function testRead()
77
61
$ this ->configFileListMock ->expects ($ this ->once ())
78
62
->method ('getEnvConfig ' )
79
63
->willReturn ($ baseDir . '/.magento.env.yaml ' );
80
- $ this ->systemListMock ->expects ($ this ->once ())
81
- ->method ('getMagentoRoot ' )
82
- ->willReturn ($ baseDir );
83
- $ this ->environmentMock ->expects ($ this ->once ())
84
- ->method ('getBranchName ' )
85
- ->willReturn ('test-branch ' );
86
64
87
65
$ this ->reader ->read ();
88
66
$ this ->assertEquals (
89
67
[
90
68
'stage ' => [
91
- 'global ' => ['SCD_ON_DEMAND ' => false , 'UPDATE_URLS ' => false ],
92
- 'deploy ' => ['DATABASE_CONFIGURATION ' => ['host ' => 'localhost ' ], 'SCD_THREADS ' => 3 ],
93
- 'build ' => ['SCD_THREADS ' => 2 ],
94
- ],
95
- 'log ' => [
96
- 'gelf ' => [
97
- 'min_level ' => 'info ' ,
98
- 'use_default_formatter ' => true ,
99
- 'additional ' => ['project ' => 'project ' ],
100
- ],
101
- 'syslog ' => ['ident ' => 'ident-branch ' , 'facility ' => 7 ],
102
- ],
103
- ],
104
- $ this ->reader ->read ()
105
- );
106
- }
107
-
108
- public function testReadBranchConfigNotExists ()
109
- {
110
- $ baseDir = __DIR__ . '/_file/ ' ;
111
-
112
- $ this ->configFileListMock ->expects ($ this ->once ())
113
- ->method ('getEnvConfig ' )
114
- ->willReturn ($ baseDir . '/.magento.env.yaml ' );
115
- $ this ->systemListMock ->expects ($ this ->once ())
116
- ->method ('getMagentoRoot ' )
117
- ->willReturn ($ baseDir );
118
- $ this ->environmentMock ->expects ($ this ->once ())
119
- ->method ('getBranchName ' )
120
- ->willReturn ('not-exist ' );
121
-
122
- $ this ->assertEquals (
123
- [
124
- 'stage ' => [
125
- 'global ' => ['SCD_ON_DEMAND ' => true , 'UPDATE_URLS ' => false ],
126
- 'deploy ' => [
127
- 'DATABASE_CONFIGURATION ' => [
128
- 'host ' => '127.0.0.1 ' ,
129
- 'port ' => '3306 ' ,
130
- 'schema ' => 'test_schema ' ,
131
- ],
132
- 'SCD_THREADS ' => 5 ,
69
+ 'global ' => [
70
+ 'SCD_ON_DEMAND ' => true ,
71
+ 'UPDATE_URLS ' => false
133
72
],
134
- ],
135
- 'log ' => [
136
- 'gelf ' => [
137
- 'min_level ' => 'info ' ,
138
- 'use_default_formatter ' => true ,
139
- 'additional ' => ['project ' => 'project ' , 'app_id ' => 'app ' ],
140
- ],
141
- ],
142
- ],
143
- $ this ->reader ->read ()
144
- );
145
- }
146
-
147
- public function testReadBranchConfigWithEmptySectionAndStage ()
148
- {
149
- $ baseDir = __DIR__ . '/_file/ ' ;
150
-
151
- $ this ->configFileListMock ->expects ($ this ->once ())
152
- ->method ('getEnvConfig ' )
153
- ->willReturn ($ baseDir . '/.magento.env.yaml ' );
154
- $ this ->systemListMock ->expects ($ this ->once ())
155
- ->method ('getMagentoRoot ' )
156
- ->willReturn ($ baseDir );
157
- $ this ->environmentMock ->expects ($ this ->once ())
158
- ->method ('getBranchName ' )
159
- ->willReturn ('test-branch-emty ' );
160
-
161
- $ this ->assertEquals (
162
- [
163
- 'stage ' => [
164
- 'global ' => ['SCD_ON_DEMAND ' => true , 'UPDATE_URLS ' => false ],
165
73
'deploy ' => [
166
- 'DATABASE_CONFIGURATION ' => [
167
- 'host ' => '127.0.0.1 ' ,
168
- 'port ' => '3306 ' ,
169
- 'schema ' => 'test_schema ' ,
170
- ],
171
- 'SCD_THREADS ' => 5 ,
74
+ 'DATABASE_CONFIGURATION ' => ['host ' => '127.0.0.1 ' , 'port ' => 3306 , 'schema ' => 'test_schema ' ],
75
+ 'SCD_THREADS ' => 5
172
76
],
173
77
],
174
78
'log ' => [
@@ -190,29 +94,16 @@ public function testReadMainConfigWithEmptySectionAndStage()
190
94
$ this ->configFileListMock ->expects ($ this ->once ())
191
95
->method ('getEnvConfig ' )
192
96
->willReturn ($ baseDir . '/.magento-with-empty-sections.env.yaml ' );
193
- $ this ->systemListMock ->expects ($ this ->once ())
194
- ->method ('getMagentoRoot ' )
195
- ->willReturn ($ baseDir );
196
- $ this ->environmentMock ->expects ($ this ->once ())
197
- ->method ('getBranchName ' )
198
- ->willReturn ('test-branch ' );
199
97
200
98
$ this ->reader ->read ();
201
99
$ this ->assertEquals (
202
100
[
203
101
'stage ' => [
204
- 'global ' => ['SCD_ON_DEMAND ' => false ],
205
- 'deploy ' => ['DATABASE_CONFIGURATION ' => ['host ' => 'localhost ' ], 'SCD_THREADS ' => 3 ],
206
- 'build ' => ['SCD_THREADS ' => 2 ],
207
- ],
208
- 'log ' => [
209
- 'gelf ' => [
210
- 'min_level ' => 'info ' ,
211
- 'use_default_formatter ' => true ,
212
- 'additional ' => ['project ' => 'project ' ],
213
- ],
214
- 'syslog ' => ['ident ' => 'ident-branch ' , 'facility ' => 7 ],
102
+ 'global ' => ['SCD_ON_DEMAND ' => true ],
103
+ 'deploy ' => null ,
104
+ 'build ' => null ,
215
105
],
106
+ 'log ' => null ,
216
107
],
217
108
$ this ->reader ->read ()
218
109
);
0 commit comments