1--TEST-- 2PharData::convertToZip|Tar|Phar() repeated (phardata_based archives) 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip"); ?> 5<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?> 6--INI-- 7phar.readonly=1 8--FILE-- 9<?php 10 11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip'; 12 13echo "=================== new PharData() ==================\n"; 14$phar = new PharData($fname); 15$phar['a'] = 'a'; 16$phar['b'] = 'b'; 17$phar['c'] = 'c'; 18 19var_dump($phar->isFileFormat(Phar::PHAR)); 20var_dump($phar->isFileFormat(Phar::TAR)); 21var_dump($phar->isFileFormat(Phar::ZIP)); 22var_dump($phar->getStub()); 23var_dump($phar->getAlias()); 24 25echo "================= convertToTar() =====================\n"; 26 27$phar = $phar->convertToData(Phar::TAR); 28var_dump($phar->isFileFormat(Phar::PHAR)); 29var_dump($phar->isFileFormat(Phar::TAR)); 30var_dump($phar->isFileFormat(Phar::ZIP)); 31var_dump($phar->getStub()); 32var_dump($phar->getAlias()); 33 34echo "================= convertToZip() =====================\n"; 35 36$phar = $phar->convertToData(Phar::ZIP, Phar::NONE, '.1.zip'); 37var_dump($phar->isFileFormat(Phar::PHAR)); 38var_dump($phar->isFileFormat(Phar::TAR)); 39var_dump($phar->isFileFormat(Phar::ZIP)); 40var_dump($phar->getStub()); 41var_dump($phar->getAlias()); 42 43echo "================= convertToPhar() ====================\n"; 44 45try { 46 $phar = $phar->convertToExecutable(Phar::PHAR); 47 var_dump($phar->isFileFormat(Phar::PHAR)); 48 var_dump($phar->isFileFormat(Phar::TAR)); 49 var_dump($phar->isFileFormat(Phar::ZIP)); 50 var_dump(strlen($phar->getStub())); 51 var_dump($phar->getAlias()); 52} catch(Exception $e) { 53 echo $e->getMessage()."\n"; 54} 55 56echo "================ convertToTar(GZ) ====================\n"; 57 58$phar = $phar->convertToData(Phar::TAR, Phar::GZ, '.2.tar'); 59var_dump($phar->isFileFormat(Phar::PHAR)); 60var_dump($phar->isFileFormat(Phar::TAR)); 61var_dump($phar->isFileFormat(Phar::ZIP)); 62var_dump($phar->getStub()); 63var_dump($phar->getAlias()); 64 65echo "================= convertToPhar() ====================\n"; 66 67try { 68 $phar = $phar->convertToExecutable(Phar::PHAR); 69 var_dump($phar->isFileFormat(Phar::PHAR)); 70 var_dump($phar->isFileFormat(Phar::TAR)); 71 var_dump($phar->isFileFormat(Phar::ZIP)); 72 var_dump(strlen($phar->getStub())); 73 var_dump($phar->getAlias()); 74} catch(Exception $e) { 75 echo $e->getMessage()."\n"; 76} 77 78?> 79===DONE=== 80--CLEAN-- 81<?php 82unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.gz'); 83unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar.gz'); 84unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); 85unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar'); 86unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip'); 87unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.zip'); 88?> 89--EXPECT-- 90=================== new PharData() ================== 91bool(false) 92bool(false) 93bool(true) 94string(0) "" 95NULL 96================= convertToTar() ===================== 97bool(false) 98bool(true) 99bool(false) 100string(0) "" 101NULL 102================= convertToZip() ===================== 103bool(false) 104bool(false) 105bool(true) 106string(0) "" 107NULL 108================= convertToPhar() ==================== 109Cannot write out executable phar archive, phar is read-only 110================ convertToTar(GZ) ==================== 111bool(false) 112bool(true) 113bool(false) 114string(0) "" 115NULL 116================= convertToPhar() ==================== 117Cannot write out executable phar archive, phar is read-only 118===DONE===