opendir.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Phar: test opendir() interception
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=1
  7. phar.readonly=0
  8. --FILE--
  9. <?php
  10. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
  11. $a = new Phar($fname);
  12. $a['index.php'] = '<?php
  13. $a = opendir("dir");
  14. if ($a) {
  15. while (false !== ($e = readdir($a))) {
  16. echo $e;
  17. }
  18. }
  19. ?>';
  20. $a['dir/file1.txt'] = 'hi';
  21. $a['dir/file2.txt'] = 'hi2';
  22. $a['dir/file3.txt'] = 'hi3';
  23. $a->setStub('<?php
  24. Phar::interceptFileFuncs();
  25. set_include_path("phar://" . __FILE__);
  26. include "index.php";
  27. __HALT_COMPILER();');
  28. include $fname;
  29. echo "\n";
  30. opendir('phar://');
  31. opendir('phar://hi.phar');
  32. ?>
  33. --CLEAN--
  34. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  35. --EXPECTF--
  36. file1.txtfile2.txtfile3.txt
  37. Warning: opendir(phar://): Failed to open directory: phar error: no directory in "phar://", must have at least phar:/// for root directory (always use full path to a new phar)
  38. phar url "phar://" is unknown in %sopendir.php on line %d
  39. Warning: opendir(phar://hi.phar): Failed to open directory: phar error: invalid url or non-existent phar "phar://hi.phar"
  40. phar url "phar://hi.phar" is unknown in %sopendir.php on line %d