xref: /PHP-7.0/ext/phar/tests/bug48377.phpt (revision 115e370d)
1--TEST--
2Phar: PHP bug #48377 "error message unclear on converting phar with existing file"
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
11$fname2 = dirname(__FILE__) . '/' . 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===DONE===
24--CLEAN--
25<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');?>
26<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');?>
27--EXPECTF--
28phar "%sbug48377.zip" exists and must be unlinked prior to conversion
29===DONE===