7
7
8
8
namespace Magento \MagentoCloud \Test \Unit \Step \Deploy ;
9
9
10
+ use Magento \MagentoCloud \Config \Magento \Env \WriterInterface ;
11
+ use Magento \MagentoCloud \Filesystem \FileSystemException ;
10
12
use Magento \MagentoCloud \Package \MagentoVersion ;
11
- use Magento \MagentoCloud \Shell \MagentoShell ;
12
- use Magento \MagentoCloud \Shell \ShellException ;
13
13
use Magento \MagentoCloud \Step \Deploy \RemoteStorage ;
14
14
use Magento \MagentoCloud \Step \StepException ;
15
15
use PHPUnit \Framework \MockObject \MockObject ;
@@ -32,11 +32,6 @@ class RemoteStorageTest extends TestCase
32
32
*/
33
33
private $ configMock ;
34
34
35
- /**
36
- * @var MagentoShell|MockObject
37
- */
38
- private $ magentoShellMock ;
39
-
40
35
/**
41
36
* @var MagentoVersion|MockObject
42
37
*/
@@ -47,21 +42,26 @@ class RemoteStorageTest extends TestCase
47
42
*/
48
43
private $ loggerMock ;
49
44
45
+ /**
46
+ * @var WriterInterface|MockObject
47
+ */
48
+ private $ writerMock ;
49
+
50
50
/**
51
51
* @inheritDoc
52
52
*/
53
53
protected function setUp (): void
54
54
{
55
55
$ this ->configMock = $ this ->createMock (Config::class);
56
56
$ this ->magentoVersionMock = $ this ->createMock (MagentoVersion::class);
57
- $ this ->magentoShellMock = $ this ->createMock (MagentoShell::class);
58
57
$ this ->loggerMock = $ this ->getMockForAbstractClass (LoggerInterface::class);
58
+ $ this ->writerMock = $ this ->getMockForAbstractClass (WriterInterface::class);
59
59
60
60
$ this ->step = new RemoteStorage (
61
61
$ this ->configMock ,
62
- $ this ->magentoShellMock ,
63
62
$ this ->magentoVersionMock ,
64
- $ this ->loggerMock
63
+ $ this ->loggerMock ,
64
+ $ this ->writerMock
65
65
);
66
66
}
67
67
@@ -80,15 +80,20 @@ public function testExecute(): void
80
80
'bucket ' => 'test_bucket ' ,
81
81
'region ' => 'test_region ' ,
82
82
]);
83
- $ this ->magentoShellMock ->expects (self ::once ())
84
- ->method ('execute ' )
85
- ->with (
86
- 'setup:config:set --remote-storage-driver=adapter '
87
- . ' --remote-storage-bucket=test_bucket --remote-storage-region=test_region -n '
88
- );
83
+ $ this ->writerMock ->expects (self ::once ())
84
+ ->method ('update ' )
85
+ ->with ([
86
+ 'remote_storage ' => [
87
+ 'driver ' => 'adapter ' ,
88
+ 'config ' => [
89
+ 'bucket ' => 'test_bucket ' ,
90
+ 'region ' => 'test_region '
91
+ ]
92
+ ]
93
+ ]);
89
94
$ this ->loggerMock ->expects (self ::once ())
90
95
->method ('info ' )
91
- ->with ('Remote storage with driver "adapter" was enabled ' );
96
+ ->with ('Remote storage driver set to: "adapter" ' );
92
97
93
98
$ this ->step ->execute ();
94
99
}
@@ -110,16 +115,24 @@ public function testExecuteWithKeys(): void
110
115
'key ' => 'test_key ' ,
111
116
'secret ' => 'test_secret '
112
117
]);
113
- $ this ->magentoShellMock ->expects (self ::once ())
114
- ->method ('execute ' )
115
- ->with (
116
- 'setup:config:set --remote-storage-driver=adapter '
117
- . ' --remote-storage-bucket=test_bucket --remote-storage-region=test_region '
118
- . ' --remote-storage-key=test_key --remote-storage-secret=test_secret -n '
119
- );
118
+ $ this ->writerMock ->expects (self ::once ())
119
+ ->method ('update ' )
120
+ ->with ([
121
+ 'remote_storage ' => [
122
+ 'driver ' => 'adapter ' ,
123
+ 'config ' => [
124
+ 'bucket ' => 'test_bucket ' ,
125
+ 'region ' => 'test_region ' ,
126
+ 'credentials ' => [
127
+ 'key ' => 'test_key ' ,
128
+ 'secret ' => 'test_secret '
129
+ ]
130
+ ]
131
+ ]
132
+ ]);
120
133
$ this ->loggerMock ->expects (self ::once ())
121
134
->method ('info ' )
122
- ->with ('Remote storage with driver "adapter" was enabled ' );
135
+ ->with ('Remote storage driver set to: "adapter" ' );
123
136
124
137
$ this ->step ->execute ();
125
138
}
@@ -143,17 +156,25 @@ public function testExecuteWithKeysAndPrefix(): void
143
156
'key ' => 'test_key ' ,
144
157
'secret ' => 'test_secret ' ,
145
158
]);
146
- $ this ->magentoShellMock ->expects (self ::once ())
147
- ->method ('execute ' )
148
- ->with (
149
- 'setup:config:set --remote-storage-driver=adapter '
150
- . ' --remote-storage-bucket=test_bucket --remote-storage-region=test_region '
151
- . ' --remote-storage-prefix=test_prefix '
152
- . ' --remote-storage-key=test_key --remote-storage-secret=test_secret -n '
153
- );
159
+ $ this ->writerMock ->expects (self ::once ())
160
+ ->method ('update ' )
161
+ ->with ([
162
+ 'remote_storage ' => [
163
+ 'driver ' => 'adapter ' ,
164
+ 'config ' => [
165
+ 'bucket ' => 'test_bucket ' ,
166
+ 'region ' => 'test_region ' ,
167
+ 'credentials ' => [
168
+ 'key ' => 'test_key ' ,
169
+ 'secret ' => 'test_secret '
170
+ ],
171
+ 'prefix ' => 'test_prefix '
172
+ ]
173
+ ]
174
+ ]);
154
175
$ this ->loggerMock ->expects (self ::once ())
155
176
->method ('info ' )
156
- ->with ('Remote storage with driver "adapter" was enabled ' );
177
+ ->with ('Remote storage driver set to: "adapter" ' );
157
178
158
179
$ this ->step ->execute ();
159
180
}
@@ -168,11 +189,9 @@ public function testExecuteDisable(): void
168
189
->willReturn (true );
169
190
$ this ->configMock ->method ('getDriver ' )
170
191
->willReturn ('' );
171
- $ this ->magentoShellMock ->expects (self ::once ())
172
- ->method ('execute ' )
173
- ->with (
174
- 'setup:config:set --remote-storage-driver=file -n '
175
- );
192
+ $ this ->writerMock ->expects (self ::once ())
193
+ ->method ('update ' )
194
+ ->with (['remote_storage ' => ['driver ' => 'file ' ]]);
176
195
177
196
$ this ->step ->execute ();
178
197
}
@@ -197,9 +216,9 @@ public function testExecuteWithException(): void
197
216
'key ' => 'test_key ' ,
198
217
'secret ' => 'test_secret '
199
218
]);
200
- $ this ->magentoShellMock ->expects (self ::once ())
201
- ->method ('execute ' )
202
- ->willThrowException (new ShellException ('Some error ' ));
219
+ $ this ->writerMock ->expects (self ::once ())
220
+ ->method ('update ' )
221
+ ->willThrowException (new FileSystemException ('Some error ' ));
203
222
$ this ->loggerMock ->expects (self ::once ())
204
223
->method ('critical ' )
205
224
->with ('Some error ' );
0 commit comments