xref: /PHP-8.2/ext/phar/tests/tar/exists_as_phar.phpt (revision 74859783)
1--TEST--
2Phar: phar-based phar named with ".tar" fails
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
12$tname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar';
13$alias = 'phar://hio';
14
15$phar = new Phar($fname);
16$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
17$phar->setAlias('hio');
18$phar->addEmptyDir('test');
19$phar->stopBuffering();
20copy($fname, $tname);
21$phar->setAlias('hio2');
22
23try {
24    $p = new Phar($tname);
25} catch (Exception $e) {
26    echo $e->getMessage() . "\n";
27}
28
29?>
30--CLEAN--
31<?php
32unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
33unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
34?>
35--EXPECTF--
36phar tar error: "%sexists_as_phar.phar.tar" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar
37