xref: /PHP-8.3/ext/phar/tests/tar/tar_nostub.phpt (revision 74859783)
1--TEST--
2Phar: tar-based phar, third-party tar with no stub, Phar->getStub()
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=1
7phar.require_hash=0
8--FILE--
9<?php
10include __DIR__ . '/files/tarmaker.php.inc';
11$fname = __DIR__ . '/tar_nostub.phar.tar';
12$alias = 'phar://' . $fname;
13$fname2 = __DIR__ . '/tar_nostub.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--CLEAN--
39<?php
40@unlink(__DIR__ . '/tar_nostub.phar.tar');
41@unlink(__DIR__ . '/tar_nostub.tar');
42?>
43--EXPECTF--
44RecursiveDirectoryIterator::__construct(phar://%star_nostub.phar.tar/): Failed to open directory: '%star_nostub.phar.tar' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive
45phar url "phar://%star_nostub.phar.tar/" is unknown
46string(0) ""
47