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