xref: /PHP-5.6/ext/phar/tests/tar/tar_nostub.phpt (revision 4f9daeed)
1--TEST--
2Phar: tar-based phar, third-party tar with no stub, Phar->getStub()
3--SKIPIF--
4<?php if (!extension_loaded('phar')) die('skip'); ?>
5<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6--INI--
7phar.readonly=1
8phar.require_hash=0
9--FILE--
10<?php
11include dirname(__FILE__) . '/files/tarmaker.php.inc';
12$fname = dirname(__FILE__) . '/tar_004.phar.tar';
13$alias = 'phar://' . $fname;
14$fname2 = dirname(__FILE__) . '/tar_004.tar';
15
16$tar = new tarmaker($fname, 'none');
17$tar->init();
18$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
19$tar->addFile('internal/file/here', "hi there!\n");
20$tar->close();
21
22try {
23	$phar = new Phar($fname);
24	var_dump($phar->getStub());
25} catch (Exception $e) {
26	echo $e->getMessage()."\n";
27}
28
29copy($fname, $fname2);
30
31try {
32	$phar = new PharData($fname2);
33	var_dump($phar->getStub());
34} catch (Exception $e) {
35	echo $e->getMessage()."\n";
36}
37
38?>
39===DONE===
40--CLEAN--
41<?php
42@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
43@unlink(dirname(__FILE__) . '/tar_004.tar');
44?>
45--EXPECTF--
46RecursiveDirectoryIterator::__construct(phar://%star_004.phar.tar/): failed to open dir: '%star_004.phar.tar' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive
47phar url "phar://%star_004.phar.tar/" is unknown
48string(0) ""
49===DONE===
50