Zip64Test.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. if (\PHP_INT_SIZE === 4) { // php 32 bit
  23. static::markTestSkipped('Only php-64 bit.');
  24. return;
  25. }
  26. $countFiles = 0xffff + 1;
  27. $zipFile = new ZipFile();
  28. for ($i = 0; $i < $countFiles; $i++) {
  29. $zipFile[$i . '.txt'] = (string) $i;
  30. }
  31. $zipFile->saveAsFile($this->outputFilename);
  32. $zipFile->close();
  33. static::assertCorrectZipArchive($this->outputFilename);
  34. $zipFile->openFile($this->outputFilename);
  35. static::assertSame($zipFile->count(), $countFiles);
  36. $i = 0;
  37. foreach ($zipFile as $entry => $content) {
  38. static::assertSame($entry, $i . '.txt');
  39. static::assertSame($content, (string) $i);
  40. $i++;
  41. }
  42. $zipFile->close();
  43. }
  44. }