ZipFinderTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the nelexa/zip package.
  5. * (c) Ne-Lexa <https://github.com/Ne-Lexa/php-zip>
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace PhpZip\Tests;
  10. use PhpZip\Constants\ZipCompressionMethod;
  11. use PhpZip\Constants\ZipOptions;
  12. use PhpZip\Exception\ZipException;
  13. use PhpZip\ZipFile;
  14. use Symfony\Component\Finder\Finder;
  15. /**
  16. * @internal
  17. *
  18. * @small
  19. */
  20. class ZipFinderTest extends ZipTestCase
  21. {
  22. /**
  23. * @throws ZipException
  24. */
  25. public function testFinder(): void
  26. {
  27. $finder = (new Finder())
  28. ->files()
  29. ->name('*.php')
  30. ->in(__DIR__)
  31. ;
  32. $zipFile = new ZipFile();
  33. $zipFile->addFromFinder(
  34. $finder,
  35. [
  36. ZipOptions::COMPRESSION_METHOD => ZipCompressionMethod::DEFLATED,
  37. ]
  38. );
  39. $zipFile->saveAsFile($this->outputFilename);
  40. static::assertCorrectZipArchive($this->outputFilename);
  41. static::assertSame($finder->count(), $zipFile->count());
  42. $zipFile->close();
  43. }
  44. }