xref: /PHP-7.3/ext/phar/tests/tar/tar_nostub.phpt (revision 84488d92)
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--INI--
6phar.readonly=1
7phar.require_hash=0
8--FILE--
9<?php
10include dirname(__FILE__) . '/files/tarmaker.php.inc';
11$fname = dirname(__FILE__) . '/tar_004.phar.tar';
12$alias = 'phar://' . $fname;
13$fname2 = dirname(__FILE__) . '/tar_004.tar';
14
15$tar = new tarmaker($fname, 'none');
16$tar->init();
17$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
18$tar->addFile('internal/file/here', "hi there!\n");
19$tar->close();
20
21try {
22	$phar = new Phar($fname);
23	var_dump($phar->getStub());
24} catch (Exception $e) {
25	echo $e->getMessage()."\n";
26}
27
28copy($fname, $fname2);
29
30try {
31	$phar = new PharData($fname2);
32	var_dump($phar->getStub());
33} catch (Exception $e) {
34	echo $e->getMessage()."\n";
35}
36
37?>
38===DONE===
39--CLEAN--
40<?php
41@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
42@unlink(dirname(__FILE__) . '/tar_004.tar');
43?>
44--EXPECTF--
45RecursiveDirectoryIterator::__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
46phar url "phar://%star_004.phar.tar/" is unknown
47string(0) ""
48===DONE===
49