@@ -43,6 +43,7 @@ class ArchiverContext implements Context {
43
43
* @var FeatureContext
44
44
*/
45
45
private FeatureContext $ featureContext ;
46
+ private SpacesContext $ spacesContext ;
46
47
47
48
/**
48
49
* @BeforeScenario
@@ -58,6 +59,7 @@ public function before(BeforeScenarioScope $scope): void {
58
59
$ environment = $ scope ->getEnvironment ();
59
60
// Get all the contexts you need in this context
60
61
$ this ->featureContext = BehatHelper::getContext ($ scope , $ environment , 'FeatureContext ' );
62
+ $ this ->spacesContext = BehatHelper::getContext ($ scope , $ environment , 'SpacesContext ' );
61
63
}
62
64
63
65
/**
@@ -120,13 +122,15 @@ private function getArchiverQueryString(
120
122
case 'id ' :
121
123
case 'ids ' :
122
124
return 'id= ' . $ this ->featureContext ->getFileIdForPath ($ user , $ resource );
125
+ case 'remoteItemIds ' :
126
+ return 'id= ' . $ this ->spacesContext ->getSharesRemoteItemId ($ user , $ resource );
123
127
case 'path ' :
124
128
case 'paths ' :
125
129
return 'path= ' . $ resource ;
126
130
default :
127
131
throw new Exception (
128
132
'" ' . $ addressType .
129
- '" is not a legal value for $addressType, must be id|ids|path|paths '
133
+ '" is not a legal value for $addressType, must be id|ids|remoteItemIds| path|paths '
130
134
);
131
135
}
132
136
}
@@ -276,7 +280,7 @@ public function theDownloadedArchiveShouldContainTheseFiles(string $type, TableN
276
280
$ tar = $ this ->getArchiveClass ($ type );
277
281
$ tar ->open ($ tempFile );
278
282
$ archiveData = $ tar ->contents ();
279
-
283
+
280
284
// extract the archive
281
285
$ tar ->open ($ tempFile );
282
286
$ tar ->extract ($ tempExtractFolder );
@@ -291,13 +295,23 @@ public function theDownloadedArchiveShouldContainTheseFiles(string $type, TableN
291
295
292
296
if ($ expectedPath === $ actualPath ) {
293
297
if (!$ info ->getIsdir ()) {
298
+ $ fileExtension = \pathinfo ($ actualPath , PATHINFO_EXTENSION );
294
299
$ fileContent = \file_get_contents ("$ tempExtractFolder/ $ actualPath " );
295
- Assert::assertEquals (
296
- $ expectedItem ['content ' ],
297
- $ fileContent ,
298
- __METHOD__ .
299
- " content of ' " . $ expectedPath . "' not as expected "
300
- );
300
+
301
+ if (\in_array ($ fileExtension , ['txt ' , 'md ' ])) {
302
+ Assert::assertEquals (
303
+ $ expectedItem ['content ' ],
304
+ $ fileContent ,
305
+ __METHOD__ . " content of ' " . $ expectedPath . "' not as expected "
306
+ );
307
+ } elseif (\in_array ($ fileExtension , ['png ' , 'jpg ' ])) {
308
+ Assert::assertFileExists (
309
+ "$ tempExtractFolder/ $ actualPath " ,
310
+ __METHOD__ . " Image file ' " . $ expectedPath . "' is not in the downloaded archive. "
311
+ );
312
+ } else {
313
+ Assert::fail ("Unsupported file type: ' $ fileExtension' for ' $ actualPath'. " );
314
+ }
301
315
}
302
316
$ found = true ;
303
317
break ;
0 commit comments