1--TEST-- 2Phar: test that creation of tar-based phar generates valid tar with all bells/whistles 3--SKIPIF-- 4<?php 5if (!extension_loaded("phar")) die("skip"); 6if (!extension_loaded("spl")) die("skip SPL not available"); 7if (!extension_loaded("zlib")) die("skip zlib not available"); 8if (!extension_loaded("bz2")) die("skip bz2 not available"); 9?> 10--INI-- 11phar.readonly=0 12--FILE-- 13<?php 14 15$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.php'; 16$pname = 'phar://' . $fname; 17$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar.php'; 18$pname2 = 'phar://' . $fname2; 19 20$phar = new Phar($fname); 21 22$phar->setMetadata('hi there'); 23$phar['a'] = 'hi'; 24$phar['a']->setMetadata('a meta'); 25$phar['b'] = 'hi2'; 26$phar['c'] = 'hi3'; 27$phar['b']->chmod(0444); 28$phar->setStub("<?php ok __HALT_COMPILER();"); 29$phar->setAlias("hime"); 30unset($phar); 31copy($fname, $fname2); 32Phar::unlinkArchive($fname); 33var_dump(file_exists($fname), file_exists($pname . '/a')); 34 35$phar = new Phar($fname2); 36var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent()); 37var_dump((string) decoct(fileperms($pname2 . '/b'))); 38var_dump($phar->getStub()); 39var_dump($phar->getAlias()); 40var_dump($phar->getMetadata()); 41var_dump($phar['a']->getMetadata()); 42?> 43===DONE=== 44--CLEAN-- 45<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar.php'); ?> 46--EXPECT-- 47bool(false) 48bool(false) 49string(2) "hi" 50string(3) "hi2" 51string(3) "hi3" 52string(6) "100444" 53string(32) "<?php ok __HALT_COMPILER(); ?> 54" 55string(4) "hime" 56string(8) "hi there" 57string(6) "a meta" 58===DONE=== 59