phar_gobyebye-win32.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d
  3. --EXTENSIONS--
  4. phar
  5. --SKIPIF--
  6. <?php if (strpos(PHP_OS, 'WIN') === false) die("skip Extra warning on Windows.");
  7. ?>
  8. --INI--
  9. phar.readonly=0
  10. --FILE--
  11. <?php
  12. Phar::interceptFileFuncs();
  13. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
  14. $fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.php';
  15. $pname = 'phar://' . $fname;
  16. file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');
  17. file_put_contents($pname . '/foo/hi', '<?php
  18. include "' . addslashes($fname2) . '";
  19. readfile("foo/hi");
  20. fopen("foo/hi", "r");
  21. echo file_get_contents("foo/hi");
  22. var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));
  23. opendir("foo/hi");
  24. ?>
  25. ');
  26. include $pname . '/foo/hi';
  27. ?>
  28. --CLEAN--
  29. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  30. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.php'); ?>
  31. --EXPECTF--
  32. Warning: readfile(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
  33. Warning: fopen(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
  34. Warning: file_get_contents(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
  35. Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
  36. bool(false)
  37. bool(false)
  38. bool(false)
  39. bool(false)
  40. bool(false)
  41. Warning: opendir(foo/hi): %s (code: 3) in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
  42. Warning: opendir(foo/hi): Failed to open directory: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d