xref: /PHP-8.3/ext/phar/tests/bug48377.phpt (revision 74859783)
1--TEST--
2Phar: PHP bug #48377 "error message unclear on converting phar with existing file"
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
11$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.zip';
12
13touch($fname2);
14
15$phar = new Phar($fname, 0, 'a.phar');
16$phar['x'] = 'hi';
17try {
18    $phar->convertToData(Phar::ZIP, Phar::NONE, 'zip');
19} catch (BadMethodCallException $e) {
20    echo $e->getMessage(),"\n";
21}
22?>
23--CLEAN--
24<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');?>
25<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.zip');?>
26--EXPECTF--
27phar "%sbug48377.zip" exists and must be unlinked prior to conversion
28