Annotation of embedaddon/php/ext/phar/tests/tar/phar_copy.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Phar: copy() tar-based
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("phar")) die("skip"); ?>
! 5: <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
! 6: <?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
! 7: --INI--
! 8: phar.readonly=0
! 9: phar.require_hash=1
! 10: --FILE--
! 11: <?php
! 12:
! 13: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
! 14: $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.php';
! 15:
! 16: $pname = 'phar://'.$fname;
! 17: $iname = '/file.txt';
! 18: $ename = '/error/..';
! 19:
! 20: $p = new Phar($fname);
! 21:
! 22: try
! 23: {
! 24: $p['a'] = 'hi';
! 25: $p->startBuffering();
! 26: $p->copy('a', 'b');
! 27: echo file_get_contents($p['b']->getPathName());
! 28: $p->copy('b', 'c');
! 29: $p->stopBuffering();
! 30: echo file_get_contents($p['c']->getPathName());
! 31: copy($fname, $fname2);
! 32: var_dump($p->isFileFormat(Phar::TAR));
! 33: $p->copy('a', $ename);
! 34: }
! 35: catch(Exception $e)
! 36: {
! 37: echo $e->getMessage() . "\n";
! 38: }
! 39: ini_set('phar.readonly',1);
! 40: $p2 = new Phar($fname2);
! 41: var_dump($p2->isFileFormat(Phar::TAR));
! 42: echo "\n";
! 43: echo 'a: ' , file_get_contents($p2['a']->getPathName());
! 44: echo 'b: ' ,file_get_contents($p2['b']->getPathName());
! 45: echo 'c: ' ,file_get_contents($p2['c']->getPathName());
! 46: ?>
! 47: ===DONE===
! 48: --CLEAN--
! 49: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.php'); ?>
! 50: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.php'); ?>
! 51: --EXPECTF--
! 52: hihibool(true)
! 53: file "/error/.." contains invalid characters upper directory reference, cannot be copied from "a" in phar %s
! 54: bool(true)
! 55:
! 56: a: hib: hic: hi===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>