metadata_read.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Phar with meta-data (read)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("phar")) die("skip");
  6. if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
  7. ?>
  8. --INI--
  9. phar.require_hash=0
  10. --FILE--
  11. <?php
  12. $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
  13. $pname = 'phar://' . $fname;
  14. $file = "<?php __HALT_COMPILER(); ?>";
  15. $files = array();
  16. $files['a'] = array('cont' => 'a');
  17. $files['b'] = array('cont' => 'b', 'meta' => 'hi there');
  18. $files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
  19. $files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
  20. include 'files/phar_test.inc';
  21. foreach($files as $name => $cont) {
  22. var_dump(file_get_contents($pname.'/'.$name));
  23. }
  24. $phar = new Phar($fname);
  25. foreach($files as $name => $cont) {
  26. var_dump($phar[$name]->getMetadata());
  27. }
  28. unset($phar);
  29. foreach($files as $name => $cont) {
  30. var_dump(file_get_contents($pname.'/'.$name));
  31. }
  32. ?>
  33. ===DONE===
  34. --CLEAN--
  35. <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  36. --EXPECT--
  37. string(1) "a"
  38. string(1) "b"
  39. string(1) "c"
  40. string(1) "d"
  41. NULL
  42. string(8) "hi there"
  43. array(2) {
  44. [0]=>
  45. string(2) "hi"
  46. [1]=>
  47. string(5) "there"
  48. }
  49. array(2) {
  50. ["hi"]=>
  51. string(5) "there"
  52. ["foo"]=>
  53. string(3) "bar"
  54. }
  55. string(1) "a"
  56. string(1) "b"
  57. string(1) "c"
  58. string(1) "d"
  59. ===DONE===