ZipFinderTest.php 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace PhpZip\Tests;
  3. use PhpZip\Constants\ZipCompressionMethod;
  4. use PhpZip\Constants\ZipOptions;
  5. use PhpZip\Exception\ZipException;
  6. use PhpZip\ZipFile;
  7. use Symfony\Component\Finder\Finder;
  8. /**
  9. * @internal
  10. *
  11. * @small
  12. */
  13. class ZipFinderTest extends ZipTestCase
  14. {
  15. /**
  16. * @throws ZipException
  17. */
  18. public function testFinder()
  19. {
  20. $finder = (new Finder())
  21. ->files()
  22. ->name('*.php')
  23. ->in(__DIR__)
  24. ;
  25. $zipFile = new ZipFile();
  26. $zipFile->addFromFinder(
  27. $finder,
  28. [
  29. ZipOptions::COMPRESSION_METHOD => ZipCompressionMethod::DEFLATED,
  30. ]
  31. );
  32. $zipFile->saveAsFile($this->outputFilename);
  33. static::assertCorrectZipArchive($this->outputFilename);
  34. static::assertSame($finder->count(), $zipFile->count());
  35. $zipFile->close();
  36. }
  37. }