xref: /PHP-7.4/ext/phar/tests/tar/exists_as_phar.phpt (revision 26dfce7f)
1--TEST--
2Phar: phar-based phar named with ".tar" fails
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
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===DONE===
31--CLEAN--
32<?php
33unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
34unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
35?>
36--EXPECTF--
37phar 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
38===DONE===
39