ZipStreamTest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <?php
  2. declare(strict_types=1);
  3. namespace ZipStreamTest;
  4. use GuzzleHttp\Psr7\Response;
  5. use org\bovigo\vfs\vfsStream;
  6. use PHPUnit\Framework\TestCase;
  7. use RecursiveDirectoryIterator;
  8. use RecursiveIteratorIterator;
  9. use ReflectionClass;
  10. use ZipArchive;
  11. use ZipStream\File;
  12. use ZipStream\Option\Archive as ArchiveOptions;
  13. use ZipStream\Option\File as FileOptions;
  14. use ZipStream\Option\Method;
  15. use ZipStream\Stream;
  16. use ZipStream\ZipStream;
  17. /**
  18. * Test Class for the Main ZipStream CLass
  19. */
  20. class ZipStreamTest extends TestCase
  21. {
  22. public const OSX_ARCHIVE_UTILITY =
  23. '/System/Library/CoreServices/Applications/Archive Utility.app/Contents/MacOS/Archive Utility';
  24. public function testFileNotFoundException(): void
  25. {
  26. $this->expectException(\ZipStream\Exception\FileNotFoundException::class);
  27. // Get ZipStream Object
  28. $zip = new ZipStream();
  29. // Trigger error by adding a file which doesn't exist
  30. $zip->addFileFromPath('foobar.php', '/foo/bar/foobar.php');
  31. }
  32. public function testFileNotReadableException(): void
  33. {
  34. // create new virtual filesystem
  35. $root = vfsStream::setup('vfs');
  36. // create a virtual file with no permissions
  37. $file = vfsStream::newFile('foo.txt', 0)->at($root)->setContent('bar');
  38. $zip = new ZipStream();
  39. $this->expectException(\ZipStream\Exception\FileNotReadableException::class);
  40. $zip->addFileFromPath('foo.txt', $file->url());
  41. }
  42. public function testDostime(): void
  43. {
  44. // Allows testing of protected method
  45. $class = new ReflectionClass(File::class);
  46. $method = $class->getMethod('dostime');
  47. $method->setAccessible(true);
  48. $this->assertSame($method->invoke(null, 1416246368), 1165069764);
  49. // January 1 1980 - DOS Epoch.
  50. $this->assertSame($method->invoke(null, 315532800), 2162688);
  51. // January 1 1970 -> January 1 1980 due to minimum DOS Epoch. @todo Throw Exception?
  52. $this->assertSame($method->invoke(null, 0), 2162688);
  53. }
  54. public function testAddFile(): void
  55. {
  56. [$tmp, $stream] = $this->getTmpFileStream();
  57. $options = new ArchiveOptions();
  58. $options->setOutputStream($stream);
  59. $zip = new ZipStream(null, $options);
  60. $zip->addFile('sample.txt', 'Sample String Data');
  61. $zip->addFile('test/sample.txt', 'More Simple Sample Data');
  62. $zip->finish();
  63. fclose($stream);
  64. $tmpDir = $this->validateAndExtractZip($tmp);
  65. $files = $this->getRecursiveFileList($tmpDir);
  66. $this->assertSame(['sample.txt', 'test' . DIRECTORY_SEPARATOR . 'sample.txt'], $files);
  67. $this->assertStringEqualsFile($tmpDir . '/sample.txt', 'Sample String Data');
  68. $this->assertStringEqualsFile($tmpDir . '/test/sample.txt', 'More Simple Sample Data');
  69. }
  70. public function testAddFileUtf8NameComment(): void
  71. {
  72. [$tmp, $stream] = $this->getTmpFileStream();
  73. $options = new ArchiveOptions();
  74. $options->setOutputStream($stream);
  75. $zip = new ZipStream(null, $options);
  76. $name = 'árvíztűrő tükörfúrógép.txt';
  77. $content = 'Sample String Data';
  78. $comment =
  79. 'Filename has every special characters ' .
  80. 'from Hungarian language in lowercase. ' .
  81. 'In uppercase: ÁÍŰŐÜÖÚÓÉ';
  82. $fileOptions = new FileOptions();
  83. $fileOptions->setComment($comment);
  84. $zip->addFile($name, $content, $fileOptions);
  85. $zip->finish();
  86. fclose($stream);
  87. $tmpDir = $this->validateAndExtractZip($tmp);
  88. $files = $this->getRecursiveFileList($tmpDir);
  89. $this->assertSame([$name], $files);
  90. $this->assertStringEqualsFile($tmpDir . '/' . $name, $content);
  91. $zipArch = new ZipArchive();
  92. $zipArch->open($tmp);
  93. $this->assertSame($comment, $zipArch->getCommentName($name));
  94. }
  95. public function testAddFileUtf8NameNonUtfComment(): void
  96. {
  97. [$tmp, $stream] = $this->getTmpFileStream();
  98. $options = new ArchiveOptions();
  99. $options->setOutputStream($stream);
  100. $zip = new ZipStream(null, $options);
  101. $name = 'á.txt';
  102. $content = 'any';
  103. $comment = mb_convert_encoding('á', 'ISO-8859-2', 'UTF-8');
  104. // @see https://libzip.org/documentation/zip_file_get_comment.html
  105. //
  106. // mb_convert_encoding hasn't CP437.
  107. // nearly CP850 (DOS-Latin-1)
  108. $guessComment = mb_convert_encoding($comment, 'UTF-8', 'CP850');
  109. $fileOptions = new FileOptions();
  110. $fileOptions->setComment($comment);
  111. $zip->addFile($name, $content, $fileOptions);
  112. $zip->finish();
  113. fclose($stream);
  114. $zipArch = new ZipArchive();
  115. $zipArch->open($tmp);
  116. $this->assertSame($guessComment, $zipArch->getCommentName($name));
  117. $this->assertSame($comment, $zipArch->getCommentName($name, ZipArchive::FL_ENC_RAW));
  118. }
  119. public function testAddFileNonUtf8NameUtfComment(): void
  120. {
  121. [$tmp, $stream] = $this->getTmpFileStream();
  122. $options = new ArchiveOptions();
  123. $options->setOutputStream($stream);
  124. $zip = new ZipStream(null, $options);
  125. $name = mb_convert_encoding('á.txt', 'ISO-8859-2', 'UTF-8');
  126. $content = 'any';
  127. $comment = 'á';
  128. // @see https://libzip.org/documentation/zip_get_name.html
  129. //
  130. // mb_convert_encoding hasn't CP437.
  131. // nearly CP850 (DOS-Latin-1)
  132. $guessName = mb_convert_encoding($name, 'UTF-8', 'CP850');
  133. $fileOptions = new FileOptions();
  134. $fileOptions->setComment($comment);
  135. $zip->addFile($name, $content, $fileOptions);
  136. $zip->finish();
  137. fclose($stream);
  138. $tmpDir = $this->validateAndExtractZip($tmp);
  139. $files = $this->getRecursiveFileList($tmpDir);
  140. $this->assertNotSame([$name], $files);
  141. $this->assertSame([$guessName], $files);
  142. $this->assertStringEqualsFile($tmpDir . '/' . $guessName, $content);
  143. $zipArch = new ZipArchive();
  144. $zipArch->open($tmp);
  145. $this->assertSame($guessName, $zipArch->getNameIndex(0));
  146. $this->assertSame($name, $zipArch->getNameIndex(0, ZipArchive::FL_ENC_RAW));
  147. $this->assertSame($comment, $zipArch->getCommentName($guessName));
  148. }
  149. public function testAddFileWithStorageMethod(): void
  150. {
  151. [$tmp, $stream] = $this->getTmpFileStream();
  152. $options = new ArchiveOptions();
  153. $options->setOutputStream($stream);
  154. $zip = new ZipStream(null, $options);
  155. $fileOptions = new FileOptions();
  156. $fileOptions->setMethod(Method::STORE());
  157. $zip->addFile('sample.txt', 'Sample String Data', $fileOptions);
  158. $zip->addFile('test/sample.txt', 'More Simple Sample Data');
  159. $zip->finish();
  160. fclose($stream);
  161. $zipArch = new ZipArchive();
  162. $zipArch->open($tmp);
  163. $sample1 = $zipArch->statName('sample.txt');
  164. $sample12 = $zipArch->statName('test/sample.txt');
  165. $this->assertSame($sample1['comp_method'], Method::STORE);
  166. $this->assertSame($sample12['comp_method'], Method::DEFLATE);
  167. $zipArch->close();
  168. }
  169. public function testDecompressFileWithMacUnarchiver(): void
  170. {
  171. if (!file_exists(self::OSX_ARCHIVE_UTILITY)) {
  172. $this->markTestSkipped('The Mac OSX Archive Utility is not available.');
  173. }
  174. [$tmp, $stream] = $this->getTmpFileStream();
  175. $options = new ArchiveOptions();
  176. $options->setOutputStream($stream);
  177. $zip = new ZipStream(null, $options);
  178. $folder = uniqid('', true);
  179. $zip->addFile($folder . '/sample.txt', 'Sample Data');
  180. $zip->finish();
  181. fclose($stream);
  182. exec(escapeshellarg(self::OSX_ARCHIVE_UTILITY) . ' ' . escapeshellarg($tmp), $output, $returnStatus);
  183. $this->assertSame(0, $returnStatus);
  184. $this->assertCount(0, $output);
  185. $this->assertFileExists(dirname($tmp) . '/' . $folder . '/sample.txt');
  186. $this->assertStringEqualsFile(dirname($tmp) . '/' . $folder . '/sample.txt', 'Sample Data');
  187. }
  188. public function testAddFileFromPath(): void
  189. {
  190. [$tmp, $stream] = $this->getTmpFileStream();
  191. $options = new ArchiveOptions();
  192. $options->setOutputStream($stream);
  193. $zip = new ZipStream(null, $options);
  194. [$tmpExample, $streamExample] = $this->getTmpFileStream();
  195. fwrite($streamExample, 'Sample String Data');
  196. fclose($streamExample);
  197. $zip->addFileFromPath('sample.txt', $tmpExample);
  198. [$tmpExample, $streamExample] = $this->getTmpFileStream();
  199. fwrite($streamExample, 'More Simple Sample Data');
  200. fclose($streamExample);
  201. $zip->addFileFromPath('test/sample.txt', $tmpExample);
  202. $zip->finish();
  203. fclose($stream);
  204. $tmpDir = $this->validateAndExtractZip($tmp);
  205. $files = $this->getRecursiveFileList($tmpDir);
  206. $this->assertSame(['sample.txt', 'test' . DIRECTORY_SEPARATOR . 'sample.txt'], $files);
  207. $this->assertStringEqualsFile($tmpDir . '/sample.txt', 'Sample String Data');
  208. $this->assertStringEqualsFile($tmpDir . '/test/sample.txt', 'More Simple Sample Data');
  209. }
  210. public function testAddFileFromPathWithStorageMethod(): void
  211. {
  212. [$tmp, $stream] = $this->getTmpFileStream();
  213. $options = new ArchiveOptions();
  214. $options->setOutputStream($stream);
  215. $zip = new ZipStream(null, $options);
  216. $fileOptions = new FileOptions();
  217. $fileOptions->setMethod(Method::STORE());
  218. [$tmpExample, $streamExample] = $this->getTmpFileStream();
  219. fwrite($streamExample, 'Sample String Data');
  220. fclose($streamExample);
  221. $zip->addFileFromPath('sample.txt', $tmpExample, $fileOptions);
  222. [$tmpExample, $streamExample] = $this->getTmpFileStream();
  223. fwrite($streamExample, 'More Simple Sample Data');
  224. fclose($streamExample);
  225. $zip->addFileFromPath('test/sample.txt', $tmpExample);
  226. $zip->finish();
  227. fclose($stream);
  228. $zipArch = new ZipArchive();
  229. $zipArch->open($tmp);
  230. $sample1 = $zipArch->statName('sample.txt');
  231. $this->assertSame(Method::STORE, $sample1['comp_method']);
  232. $sample2 = $zipArch->statName('test/sample.txt');
  233. $this->assertSame(Method::DEFLATE, $sample2['comp_method']);
  234. $zipArch->close();
  235. }
  236. public function testAddLargeFileFromPath(): void
  237. {
  238. $methods = [Method::DEFLATE(), Method::STORE()];
  239. $falseTrue = [false, true];
  240. foreach ($methods as $method) {
  241. foreach ($falseTrue as $zeroHeader) {
  242. foreach ($falseTrue as $zip64) {
  243. if ($zeroHeader && $method->equals(Method::DEFLATE())) {
  244. continue;
  245. }
  246. $this->addLargeFileFileFromPath($method, $zeroHeader, $zip64);
  247. }
  248. }
  249. }
  250. }
  251. public function testAddFileFromStream(): void
  252. {
  253. [$tmp, $stream] = $this->getTmpFileStream();
  254. $options = new ArchiveOptions();
  255. $options->setOutputStream($stream);
  256. $zip = new ZipStream(null, $options);
  257. // In this test we can't use temporary stream to feed data
  258. // because zlib.deflate filter gives empty string before PHP 7
  259. // it works fine with file stream
  260. $streamExample = fopen(__FILE__, 'rb');
  261. $zip->addFileFromStream('sample.txt', $streamExample);
  262. // fclose($streamExample);
  263. $fileOptions = new FileOptions();
  264. $fileOptions->setMethod(Method::STORE());
  265. $streamExample2 = fopen('php://temp', 'wb+');
  266. fwrite($streamExample2, 'More Simple Sample Data');
  267. rewind($streamExample2); // move the pointer back to the beginning of file.
  268. $zip->addFileFromStream('test/sample.txt', $streamExample2, $fileOptions);
  269. // fclose($streamExample2);
  270. $zip->finish();
  271. fclose($stream);
  272. $tmpDir = $this->validateAndExtractZip($tmp);
  273. $files = $this->getRecursiveFileList($tmpDir);
  274. $this->assertSame(['sample.txt', 'test' . DIRECTORY_SEPARATOR . 'sample.txt'], $files);
  275. $this->assertStringEqualsFile(__FILE__, file_get_contents($tmpDir . '/sample.txt'));
  276. $this->assertStringEqualsFile($tmpDir . '/test/sample.txt', 'More Simple Sample Data');
  277. }
  278. public function testAddFileFromStreamWithStorageMethod(): void
  279. {
  280. [$tmp, $stream] = $this->getTmpFileStream();
  281. $options = new ArchiveOptions();
  282. $options->setOutputStream($stream);
  283. $zip = new ZipStream(null, $options);
  284. $fileOptions = new FileOptions();
  285. $fileOptions->setMethod(Method::STORE());
  286. $streamExample = fopen('php://temp', 'wb+');
  287. fwrite($streamExample, 'Sample String Data');
  288. rewind($streamExample); // move the pointer back to the beginning of file.
  289. $zip->addFileFromStream('sample.txt', $streamExample, $fileOptions);
  290. // fclose($streamExample);
  291. $streamExample2 = fopen('php://temp', 'bw+');
  292. fwrite($streamExample2, 'More Simple Sample Data');
  293. rewind($streamExample2); // move the pointer back to the beginning of file.
  294. $zip->addFileFromStream('test/sample.txt', $streamExample2);
  295. // fclose($streamExample2);
  296. $zip->finish();
  297. fclose($stream);
  298. $zipArch = new ZipArchive();
  299. $zipArch->open($tmp);
  300. $sample1 = $zipArch->statName('sample.txt');
  301. $this->assertSame(Method::STORE, $sample1['comp_method']);
  302. $sample2 = $zipArch->statName('test/sample.txt');
  303. $this->assertSame(Method::DEFLATE, $sample2['comp_method']);
  304. $zipArch->close();
  305. }
  306. public function testAddFileFromPsr7Stream(): void
  307. {
  308. [$tmp, $stream] = $this->getTmpFileStream();
  309. $options = new ArchiveOptions();
  310. $options->setOutputStream($stream);
  311. $zip = new ZipStream(null, $options);
  312. $body = 'Sample String Data';
  313. $response = new Response(200, [], $body);
  314. $fileOptions = new FileOptions();
  315. $fileOptions->setMethod(Method::STORE());
  316. $zip->addFileFromPsr7Stream('sample.json', $response->getBody(), $fileOptions);
  317. $zip->finish();
  318. fclose($stream);
  319. $tmpDir = $this->validateAndExtractZip($tmp);
  320. $files = $this->getRecursiveFileList($tmpDir);
  321. $this->assertSame(['sample.json'], $files);
  322. $this->assertStringEqualsFile($tmpDir . '/sample.json', $body);
  323. }
  324. public function testAddFileFromPsr7StreamWithOutputToPsr7Stream(): void
  325. {
  326. [$tmp, $resource] = $this->getTmpFileStream();
  327. $psr7OutputStream = new Stream($resource);
  328. $options = new ArchiveOptions();
  329. $options->setOutputStream($psr7OutputStream);
  330. $zip = new ZipStream(null, $options);
  331. $body = 'Sample String Data';
  332. $response = new Response(200, [], $body);
  333. $fileOptions = new FileOptions();
  334. $fileOptions->setMethod(Method::STORE());
  335. $zip->addFileFromPsr7Stream('sample.json', $response->getBody(), $fileOptions);
  336. $zip->finish();
  337. $psr7OutputStream->close();
  338. $tmpDir = $this->validateAndExtractZip($tmp);
  339. $files = $this->getRecursiveFileList($tmpDir);
  340. $this->assertSame(['sample.json'], $files);
  341. $this->assertStringEqualsFile($tmpDir . '/sample.json', $body);
  342. }
  343. public function testAddFileFromPsr7StreamWithFileSizeSet(): void
  344. {
  345. [$tmp, $stream] = $this->getTmpFileStream();
  346. $options = new ArchiveOptions();
  347. $options->setOutputStream($stream);
  348. $zip = new ZipStream(null, $options);
  349. $body = 'Sample String Data';
  350. $fileSize = strlen($body);
  351. // Add fake padding
  352. $fakePadding = "\0\0\0\0\0\0";
  353. $response = new Response(200, [], $body . $fakePadding);
  354. $fileOptions = new FileOptions();
  355. $fileOptions->setMethod(Method::STORE());
  356. $fileOptions->setSize($fileSize);
  357. $zip->addFileFromPsr7Stream('sample.json', $response->getBody(), $fileOptions);
  358. $zip->finish();
  359. fclose($stream);
  360. $tmpDir = $this->validateAndExtractZip($tmp);
  361. $files = $this->getRecursiveFileList($tmpDir);
  362. $this->assertSame(['sample.json'], $files);
  363. $this->assertStringEqualsFile($tmpDir . '/sample.json', $body);
  364. }
  365. public function testCreateArchiveWithFlushOptionSet(): void
  366. {
  367. [$tmp, $stream] = $this->getTmpFileStream();
  368. $options = new ArchiveOptions();
  369. $options->setOutputStream($stream);
  370. $options->setFlushOutput(true);
  371. $zip = new ZipStream(null, $options);
  372. $zip->addFile('sample.txt', 'Sample String Data');
  373. $zip->addFile('test/sample.txt', 'More Simple Sample Data');
  374. $zip->finish();
  375. fclose($stream);
  376. $tmpDir = $this->validateAndExtractZip($tmp);
  377. $files = $this->getRecursiveFileList($tmpDir);
  378. $this->assertSame(['sample.txt', 'test' . DIRECTORY_SEPARATOR . 'sample.txt'], $files);
  379. $this->assertStringEqualsFile($tmpDir . '/sample.txt', 'Sample String Data');
  380. $this->assertStringEqualsFile($tmpDir . '/test/sample.txt', 'More Simple Sample Data');
  381. }
  382. public function testCreateArchiveWithOutputBufferingOffAndFlushOptionSet(): void
  383. {
  384. // WORKAROUND (1/2): remove phpunit's output buffer in order to run test without any buffering
  385. ob_end_flush();
  386. $this->assertSame(0, ob_get_level());
  387. [$tmp, $stream] = $this->getTmpFileStream();
  388. $options = new ArchiveOptions();
  389. $options->setOutputStream($stream);
  390. $options->setFlushOutput(true);
  391. $zip = new ZipStream(null, $options);
  392. $zip->addFile('sample.txt', 'Sample String Data');
  393. $zip->finish();
  394. fclose($stream);
  395. $tmpDir = $this->validateAndExtractZip($tmp);
  396. $this->assertStringEqualsFile($tmpDir . '/sample.txt', 'Sample String Data');
  397. // WORKAROUND (2/2): add back output buffering so that PHPUnit doesn't complain that it is missing
  398. ob_start();
  399. }
  400. /**
  401. * @return array
  402. */
  403. protected function getTmpFileStream(): array
  404. {
  405. $tmp = tempnam(sys_get_temp_dir(), 'zipstreamtest');
  406. $stream = fopen($tmp, 'wb+');
  407. return [$tmp, $stream];
  408. }
  409. /**
  410. * @param string $tmp
  411. * @return string
  412. */
  413. protected function validateAndExtractZip($tmp): string
  414. {
  415. $tmpDir = $this->getTmpDir();
  416. $zipArch = new ZipArchive();
  417. $res = $zipArch->open($tmp);
  418. if ($res !== true) {
  419. $this->fail("Failed to open {$tmp}. Code: $res");
  420. return $tmpDir;
  421. }
  422. $this->assertSame(0, $zipArch->status);
  423. $this->assertSame(0, $zipArch->statusSys);
  424. $zipArch->extractTo($tmpDir);
  425. $zipArch->close();
  426. return $tmpDir;
  427. }
  428. protected function getTmpDir(): string
  429. {
  430. $tmp = tempnam(sys_get_temp_dir(), 'zipstreamtest');
  431. unlink($tmp);
  432. mkdir($tmp) or $this->fail('Failed to make directory');
  433. return $tmp;
  434. }
  435. /**
  436. * @param string $path
  437. * @return string[]
  438. */
  439. protected function getRecursiveFileList(string $path): array
  440. {
  441. $data = [];
  442. $path = (string)realpath($path);
  443. $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
  444. $pathLen = strlen($path);
  445. foreach ($files as $file) {
  446. $filePath = $file->getRealPath();
  447. if (!is_dir($filePath)) {
  448. $data[] = substr($filePath, $pathLen + 1);
  449. }
  450. }
  451. sort($data);
  452. return $data;
  453. }
  454. protected function addLargeFileFileFromPath($method, $zeroHeader, $zip64): void
  455. {
  456. [$tmp, $stream] = $this->getTmpFileStream();
  457. $options = new ArchiveOptions();
  458. $options->setOutputStream($stream);
  459. $options->setLargeFileMethod($method);
  460. $options->setLargeFileSize(5);
  461. $options->setZeroHeader($zeroHeader);
  462. $options->setEnableZip64($zip64);
  463. $zip = new ZipStream(null, $options);
  464. [$tmpExample, $streamExample] = $this->getTmpFileStream();
  465. for ($i = 0; $i <= 10000; $i++) {
  466. fwrite($streamExample, sha1((string)$i));
  467. if ($i % 100 === 0) {
  468. fwrite($streamExample, "\n");
  469. }
  470. }
  471. fclose($streamExample);
  472. $shaExample = sha1_file($tmpExample);
  473. $zip->addFileFromPath('sample.txt', $tmpExample);
  474. unlink($tmpExample);
  475. $zip->finish();
  476. fclose($stream);
  477. $tmpDir = $this->validateAndExtractZip($tmp);
  478. $files = $this->getRecursiveFileList($tmpDir);
  479. $this->assertSame(['sample.txt'], $files);
  480. $this->assertSame(sha1_file($tmpDir . '/sample.txt'), $shaExample, "SHA-1 Mismatch Method: {$method}");
  481. }
  482. }