Annotation of embedaddon/php/ext/phar/tests/phar_copy.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Phar: copy()
                      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.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['a']->compress(Phar::GZ);
                     29:        $p['b']->setMetadata('a');
                     30:        $p->copy('b', 'c');
                     31:        $p->stopBuffering();
                     32:        echo file_get_contents($p['c']->getPathName());
                     33:        copy($fname, $fname2);
                     34:        $p->copy('a', $ename);
                     35: }
                     36: catch(Exception $e)
                     37: {
                     38:        echo $e->getMessage() . "\n";
                     39: }
                     40: ini_set('phar.readonly',1);
                     41: $p2 = new Phar($fname2);
                     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()), $p2['c']->getMetaData(), "\n";
                     46: ini_set('phar.readonly', 0);
                     47: try {
                     48: $p2->copy('notexisting', 'another');
                     49: } catch (Exception $e) {
                     50: echo $e->getMessage() . "\n";
                     51: }
                     52: try {
                     53: $p2->copy('a', 'b');
                     54: } catch (Exception $e) {
                     55: echo $e->getMessage() . "\n";
                     56: }
                     57: $p2['a']->compress(Phar::GZ);
                     58: $p2->copy('a', 'd');
                     59: echo $p2['d']->getContent() . "\n";
                     60: try {
                     61: $p2->copy('d', '.phar/stub.php');
                     62: } catch (Exception $e) {
                     63: echo $e->getMessage(),"\n";
                     64: }
                     65: try {
                     66: $p2->copy('.phar/stub.php', 'd');
                     67: } catch (Exception $e) {
                     68: echo $e->getMessage(),"\n";
                     69: }
                     70: ?>
                     71: ===DONE===
                     72: --CLEAN--
                     73: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
                     74: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.php'); ?>
                     75: --EXPECTF--
                     76: hihifile "/error/.." contains invalid characters upper directory reference, cannot be copied from "a" in phar %s
                     77: 
                     78: a: hib: hic: hia
                     79: file "notexisting" cannot be copied to file "another", file does not exist in %sphar_copy2.phar.php
                     80: file "a" cannot be copied to file "b", file must not already exist in phar %sphar_copy2.phar.php
                     81: hi
                     82: file "d" cannot be copied to file ".phar/stub.php", cannot copy to Phar meta-file in %sphar_copy2.phar.php
                     83: file ".phar/stub.php" cannot be copied to file "d", cannot copy Phar meta-file in %sphar_copy2.phar.php
                     84: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>