xref: /PHP-7.4/ext/phar/tests/bug13786.phpt (revision 26dfce7f)
1--TEST--
2Phar: bug #13786: "PHP crashes on phar recreate after unlink"
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11try {
12for ($i = 0; $i < 2; $i++) {
13	$fname = "DataArchive.phar";
14	$path = __DIR__ . DIRECTORY_SEPARATOR . $fname;
15	$phar = new Phar($path);
16	$phar->addFromString($i, "file $i in $fname");
17	var_dump(file_get_contents($phar[$i]));
18	unset($phar);
19	unlink($path);
20}
21
22echo("\nWritten files: $i\n");
23} catch (Exception $e) {
24echo $e->getMessage() . "\n";
25}
26
27?>
28===DONE===
29--EXPECTF--
30string(26) "file 0 in DataArchive.phar"
31unable to seek to start of file "0" while creating new phar "%sDataArchive.phar"
32===DONE===
33