Zip64Test.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace PhpZip\Tests;
  3. use PhpZip\Exception\ZipException;
  4. use PhpZip\ZipFile;
  5. /**
  6. * Class Zip64Test.
  7. *
  8. * @internal
  9. *
  10. * @medium
  11. */
  12. class Zip64Test extends ZipTestCase
  13. {
  14. /**
  15. * Test support ZIP64 ext (slow test - normal).
  16. * Create > 65535 files in archive and open and extract to /dev/null.
  17. *
  18. * @throws ZipException
  19. */
  20. public function testOver65535FilesInZip()
  21. {
  22. $countFiles = 0xffff + 1;
  23. $zipFile = new ZipFile();
  24. for ($i = 0; $i < $countFiles; $i++) {
  25. $zipFile[$i . '.txt'] = (string) $i;
  26. }
  27. $zipFile->saveAsFile($this->outputFilename);
  28. $zipFile->close();
  29. static::assertCorrectZipArchive($this->outputFilename);
  30. $zipFile->openFile($this->outputFilename);
  31. static::assertSame($zipFile->count(), $countFiles);
  32. $i = 0;
  33. foreach ($zipFile as $entry => $content) {
  34. static::assertSame($entry, $i . '.txt');
  35. static::assertSame($content, (string) $i);
  36. $i++;
  37. }
  38. $zipFile->close();
  39. }
  40. }