xref: /PHP-8.2/ext/phar/tests/zip/exists_as_phar.phpt (revision 74859783)
1--TEST--
2Phar: phar-based phar named with ".zip" 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.zip';
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.zip');
33unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
34?>
35--EXPECTF--
36phar zip error: phar "%sexists_as_phar.phar.zip" already exists as a regular phar and must be deleted from disk prior to creating as a zip-based phar
37