Annotation of embedaddon/php/ext/phar/tests/phar_mount.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Phar: Phar::mount
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("phar")) die("skip"); ?>
! 5: --INI--
! 6: phar.readonly=0
! 7: --FILE--
! 8: <?php
! 9: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
! 10: $pname = 'phar://' . $fname;
! 11: $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
! 12:
! 13: $a = new Phar($fname);
! 14: $a['index.php'] = '<?php
! 15: Phar::mount("testit", "' . addslashes(__FILE__) . '");
! 16: try {
! 17: Phar::mount("testit", "' . addslashes(__FILE__) . '");
! 18: } catch (Exception $e) {
! 19: echo $e->getMessage() . "\n";
! 20: }
! 21: try {
! 22: Phar::mount("' . addslashes($pname) . '/testit1", "' . addslashes(__FILE__) . '");
! 23: } catch (Exception $e) {
! 24: echo $e->getMessage() . "\n";
! 25: }
! 26: ?>';
! 27: $a->setStub('<?php
! 28: set_include_path("phar://" . __FILE__);
! 29: include "index.php";
! 30: __HALT_COMPILER();');
! 31: Phar::mount($pname . '/testit1', __FILE__);
! 32: include $fname;
! 33: // test copying of a phar with mounted entries
! 34: $b = $a->convertToExecutable(Phar::TAR);
! 35: $b->setStub('<?php
! 36: set_include_path("phar://" . __FILE__);
! 37: include "index.php";
! 38: __HALT_COMPILER();');
! 39: try {
! 40: include $fname2;
! 41: } catch (Exception $e) {
! 42: echo $e->getMessage(),"\n";
! 43: }
! 44: try {
! 45: Phar::mount($pname . '/oops', '/home/oops/../../etc/passwd:');
! 46: } catch (Exception $e) {
! 47: echo $e->getMessage(),"\n";
! 48: }
! 49: Phar::mount($pname . '/testit2', $pname . '/testit1');
! 50: echo substr($a['testit2']->getContent(),0, 50),"\n";
! 51: ?>
! 52: ===DONE===
! 53: --CLEAN--
! 54: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
! 55: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
! 56: --EXPECTF--
! 57: Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.php failed
! 58: Can only mount internal paths within a phar archive, use a relative path instead of "phar://%sphar_mount.phar.php/testit1"
! 59: Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.tar failed
! 60: Mounting of /oops to /home/oops/../../etc/passwd: within phar %sphar_mount.phar.php failed
! 61: <?php
! 62: $fname = dirname(__FILE__) . '/' . basename(
! 63: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>