metadata_read.phpt 1.2 KB

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