delete_in_phar_confirm.phpt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. Phar: delete a file within a .phar (confirm disk file is changed)
  3. --SKIPIF--
  4. <?php if (!extension_loaded("phar")) die("skip"); ?>
  5. --INI--
  6. phar.readonly=0
  7. phar.require_hash=0
  8. --FILE--
  9. <?php
  10. $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
  11. $pname = 'phar://' . $fname;
  12. $file = "<?php __HALT_COMPILER(); ?>";
  13. $files = array();
  14. $files['a.php'] = '<?php echo "This is a\n"; ?>';
  15. $files['b.php'] = '<?php echo "This is b\n"; ?>';
  16. $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
  17. if (function_exists("opcache_get_status")) {
  18. $status = opcache_get_status();
  19. if ($status["opcache_enabled"]) {
  20. ini_set("opcache.revalidate_freq", "0");
  21. sleep(2);
  22. }
  23. }
  24. include 'files/phar_test.inc';
  25. include $pname . '/a.php';
  26. include $pname . '/b.php';
  27. include $pname . '/b/c.php';
  28. $md5 = md5_file($fname);
  29. unlink($pname . '/b/c.php');
  30. clearstatcache();
  31. $md52 = md5_file($fname);
  32. if ($md5 == $md52) echo 'file was not modified';
  33. ?>
  34. ===AFTER===
  35. <?php
  36. include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
  37. include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
  38. include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
  39. ?>
  40. ===DONE===
  41. --CLEAN--
  42. <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  43. --EXPECTF--
  44. This is a
  45. This is b
  46. This is b/c
  47. ===AFTER===
  48. This is a
  49. This is b
  50. Warning: include(%sdelete_in_phar_confirm.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.php" in %sdelete_in_phar_confirm.php on line %d
  51. Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
  52. ===DONE===