delete_in_phar.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Phar: delete a file within a .phar
  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. unlink($pname . '/b/c.php');
  29. ?>
  30. ===AFTER===
  31. <?php
  32. include $pname . '/a.php';
  33. include $pname . '/b.php';
  34. include $pname . '/b/c.php';
  35. ?>
  36. ===DONE===
  37. --CLEAN--
  38. <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  39. --EXPECTF--
  40. This is a
  41. This is b
  42. This is b/c
  43. ===AFTER===
  44. This is a
  45. This is b
  46. Warning: include(%sdelete_in_phar.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.php" in %sdelete_in_phar.php on line %d
  47. Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
  48. ===DONE===