1--TEST-- 2Phar: mounted manifest directory test 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6?> 7--INI-- 8phar.readonly=0 9--FILE-- 10<?php 11$fname = dirname(__FILE__) . '/tempmanifest1.phar.php'; 12$pname = 'phar://' . $fname; 13 14$a = new Phar($fname); 15$a['index.php'] = '<?php 16Phar::mount("testit", dirname(Phar::running(0)) . "/testit"); 17echo file_get_contents(Phar::running(1) . "/testit/extfile.php"), "\n"; 18echo file_get_contents(Phar::running(1) . "/testit/directory"), "\n"; 19echo file_get_contents(Phar::running(1) . "/testit/existing.txt"), "\n"; 20include "testit/extfile.php"; 21include "testit/extfile2.php"; 22try { 23Phar::mount(".phar/stub.php", dirname(Phar::running(0)) . "/testit/extfile.php"); 24} catch (Exception $e) { 25echo $e->getMessage(),"\n"; 26} 27?>'; 28$a['testit/existing.txt'] = 'oops'; 29$a->setStub('<?php 30set_include_path("phar://" . __FILE__); 31include "index.php"; 32__HALT_COMPILER();'); 33unset($a); 34mkdir(dirname(__FILE__) . '/testit'); 35mkdir(dirname(__FILE__) . '/testit/directory'); 36file_put_contents(dirname(__FILE__) . '/testit/extfile.php', '<?php 37var_dump(__FILE__); 38?>'); 39file_put_contents(dirname(__FILE__) . '/testit/extfile2.php', '<?php 40var_dump(__FILE__); 41?>'); 42include dirname(__FILE__) . '/testit/extfile.php'; 43include $fname; 44 45$a = opendir($pname . '/testit'); 46$out = array(); 47while (false !== ($b = readdir($a))) { 48 $out[] = $b; 49} 50sort($out); 51foreach ($out as $b) { 52 echo "$b\n"; 53} 54$out = array(); 55foreach (new Phar($pname . '/testit') as $b) { 56 $out[] = $b->getPathName(); 57} 58sort($out); 59foreach ($out as $b) { 60 echo "$b\n"; 61} 62try { 63Phar::mount($pname . '/testit', 'another\\..\\mistake'); 64} catch (Exception $e) { 65echo $e->getMessage(), "\n"; 66} 67try { 68Phar::mount($pname . '/notfound', dirname(__FILE__) . '/this/does/not/exist'); 69} catch (Exception $e) { 70echo $e->getMessage(), "\n"; 71} 72try { 73Phar::mount($pname . '/testit', dirname(__FILE__)); 74} catch (Exception $e) { 75echo $e->getMessage(), "\n"; 76} 77try { 78Phar::mount($pname . '/testit/extfile.php', dirname(__FILE__)); 79} catch (Exception $e) { 80echo $e->getMessage(), "\n"; 81} 82?> 83===DONE=== 84--CLEAN-- 85<?php 86@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php'); 87@unlink(dirname(__FILE__) . '/testit/extfile.php'); 88@unlink(dirname(__FILE__) . '/testit/extfile2.php'); 89@rmdir(dirname(__FILE__) . '/testit/directory'); 90@rmdir(dirname(__FILE__) . '/testit'); 91 92?> 93--EXPECTF-- 94string(%d) "%sextfile.php" 95<?php 96var_dump(__FILE__); 97?> 98 99Warning: file_get_contents(phar://%stempmanifest1.phar.php/testit/directory): failed to open stream: phar error: path "testit/directory" is a directory in phar://%stempmanifest1.phar.php/index.php on line %d 100 101oops 102string(%d) "phar://%sextfile.php" 103string(%d) "phar://%sextfile2.php" 104Mounting of .phar/stub.php to %sextfile.php within phar %stests/tempmanifest1.phar.php failed 105. 106.. 107directory 108extfile.php 109extfile2.php 110phar://%stempmanifest1.phar.php/testit%cdirectory 111phar://%stempmanifest1.phar.php/testit%cextfile.php 112phar://%stempmanifest1.phar.php/testit%cextfile2.php 113Mounting of /testit to another\..\mistake within phar %stempmanifest1.phar.php failed 114Mounting of /notfound to %stests/this/does/not/exist within phar %stempmanifest1.phar.php failed 115Mounting of /testit to %stests within phar %stests/tempmanifest1.phar.php failed 116Mounting of /testit/extfile.php to %stests within phar %stests/tempmanifest1.phar.php failed 117===DONE=== 118