File tree 2 files changed +24
-8
lines changed
2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -130,20 +130,24 @@ public function __construct(
130
130
*/
131
131
public function prepareDownloadArchive ()
132
132
{
133
- $ path = $ this ->directoryList ->getPath (DirectoryList::TMP ) . '/bitpay-support.zip ' ;
133
+ $ zipDir = $ this ->directoryList ->getPath (DirectoryList::TMP ) . DIRECTORY_SEPARATOR ;
134
+ if (!$ this ->fileDriver ->isExists ($ zipDir )) {
135
+ $ this ->fileDriver ->createDirectory ($ zipDir );
136
+ }
137
+ $ zipPath = $ zipDir . 'bitpay-support.zip ' ;
134
138
135
- $ this ->zipArchive ->open ($ path , \ ZipArchive::CREATE );
139
+ $ this ->zipArchive ->open ($ zipPath , ZipArchive::CREATE | ZipArchive:: OVERWRITE );
136
140
$ this ->zipArchive ->addFromString (
137
141
'bitpay-support.json ' ,
138
142
$ this ->jsonSerializer ->serialize ($ this ->prepareSupportDetails ())
139
143
);
140
- $ logPath = $ this ->directoryList ->getPath (DirectoryList::LOG ) . ' / bitpay.log ' ;
144
+ $ logPath = $ this ->directoryList ->getPath (DirectoryList::LOG ) . DIRECTORY_SEPARATOR . ' bitpay.log ' ;
141
145
if ($ this ->fileDriver ->isExists ($ logPath )) {
142
146
$ this ->zipArchive ->addFile ($ logPath , 'bitpay.log ' );
143
147
}
144
148
$ this ->zipArchive ->close ();
145
149
146
- return $ path ;
150
+ return $ zipPath ;
147
151
}
148
152
149
153
/**
Original file line number Diff line number Diff line change @@ -184,9 +184,21 @@ public function testPrepareDownloadArchive()
184
184
[DirectoryList::LOG , '/log ' ]
185
185
]));
186
186
187
- $ this ->fileDriverMock ->method ('isExists ' )
188
- ->with ($ logPath )
189
- ->willReturn (true );
187
+ $ invokedCount = $ this ->exactly (2 );
188
+ $ this ->fileDriverMock ->expects ($ invokedCount )
189
+ ->method ('isExists ' )
190
+ ->willReturnCallback (function ($ parameters ) use ($ invokedCount , $ tmpPath , $ logPath ) {
191
+ if ($ invokedCount ->getInvocationCount () === 1 ) {
192
+ $ this ->assertSame ($ tmpPath . '/ ' , $ parameters );
193
+
194
+ return true ;
195
+ }
196
+
197
+ if ($ invokedCount ->getInvocationCount () === 2 ) {
198
+ $ this ->assertSame ($ logPath , $ parameters );
199
+ return true ;
200
+ }
201
+ });
190
202
191
203
$ this ->jsonSerializerMock ->method ('serialize ' )
192
204
->willReturn ('{"key":"value"} ' );
@@ -215,7 +227,7 @@ public function testPrepareDownloadArchive()
215
227
216
228
$ this ->zipArchiveMock ->expects ($ this ->once ())
217
229
->method ('open ' )
218
- ->with ($ archivePath , \ ZipArchive::CREATE )
230
+ ->with ($ archivePath , ZipArchive::CREATE | ZipArchive:: OVERWRITE )
219
231
->willReturn (true );
220
232
$ this ->zipArchiveMock ->expects ($ this ->once ())
221
233
->method ('addFromString ' )
You can’t perform that action at this time.
0 commit comments