Annotation of embedaddon/php/ext/phar/tests/phar_buildfromiterator4.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Phar::buildFromIterator() iterator, 1 file passed in
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("phar")) die("skip"); ?>
! 5: --INI--
! 6: phar.require_hash=0
! 7: phar.readonly=0
! 8: --FILE--
! 9: <?php
! 10: class myIterator implements Iterator
! 11: {
! 12: var $a;
! 13: function __construct(array $a)
! 14: {
! 15: $this->a = $a;
! 16: }
! 17: function next() {
! 18: echo "next\n";
! 19: return next($this->a);
! 20: }
! 21: function current() {
! 22: echo "current\n";
! 23: return current($this->a);
! 24: }
! 25: function key() {
! 26: echo "key\n";
! 27: return key($this->a);
! 28: }
! 29: function valid() {
! 30: echo "valid\n";
! 31: return current($this->a);
! 32: }
! 33: function rewind() {
! 34: echo "rewind\n";
! 35: return reset($this->a);
! 36: }
! 37: }
! 38: try {
! 39: chdir(dirname(__FILE__));
! 40: $phar = new Phar(dirname(__FILE__) . '/buildfromiterator.phar');
! 41: var_dump($phar->buildFromIterator(new myIterator(
! 42: array(
! 43: 'a' => basename(__FILE__, 'php') . 'phpt',
! 44: // demonstrate that none of these are added
! 45: '.phar/stub.php' => basename(__FILE__, 'php') . 'phpt',
! 46: '.phar/alias.txt' => basename(__FILE__, 'php') . 'phpt',
! 47: '.phar/oops' => basename(__FILE__, 'php') . 'phpt',
! 48: ))));
! 49: } catch (Exception $e) {
! 50: var_dump(get_class($e));
! 51: echo $e->getMessage() . "\n";
! 52: }
! 53: ?>
! 54: ===DONE===
! 55: --CLEAN--
! 56: <?php
! 57: unlink(dirname(__FILE__) . '/buildfromiterator.phar');
! 58: __HALT_COMPILER();
! 59: ?>
! 60: --EXPECTF--
! 61: rewind
! 62: valid
! 63: current
! 64: key
! 65: next
! 66: valid
! 67: current
! 68: key
! 69: next
! 70: valid
! 71: current
! 72: key
! 73: next
! 74: valid
! 75: current
! 76: key
! 77: next
! 78: valid
! 79: array(1) {
! 80: ["a"]=>
! 81: string(%d) "%sphar_buildfromiterator4.phpt"
! 82: }
! 83: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>