pharfileinfo_getcrc32.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Phar: PharFileInfo::getCRC32
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. phar.readonly=0
  8. --FILE--
  9. <?php
  10. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
  11. $pname = 'phar://' . $fname;
  12. $file = "<?php
  13. Phar::mapPhar('hio');
  14. __HALT_COMPILER(); ?>";
  15. // compressed file length does not match incompressed length for an uncompressed file
  16. $files = array();
  17. $files['a/subdir/here'] = array('cont'=>'a','ulen'=>1,'clen'=>1);
  18. include 'files/phar_test.inc';
  19. $b = new PharFileInfo($pname . '/a/subdir');
  20. try {
  21. var_dump($b->getCRC32());
  22. } catch (Exception $e) {
  23. echo $e->getMessage() . "\n";
  24. }
  25. $b = new PharFileInfo($pname . '/a/subdir/here');
  26. try {
  27. var_dump($b->getCRC32());
  28. } catch (Exception $e) {
  29. echo $e->getMessage() . "\n";
  30. }
  31. $a = file_get_contents($pname . '/a/subdir/here');
  32. try {
  33. var_dump($b->getCRC32());
  34. } catch (Exception $e) {
  35. echo $e->getMessage() . "\n";
  36. }
  37. ?>
  38. --CLEAN--
  39. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
  40. --EXPECTF--
  41. Phar entry is a directory, does not have a CRC
  42. Phar entry was not CRC checked
  43. int(%s)