1--TEST--
2Phar: PharFileInfo::__construct
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
10$pname = 'phar://' . $fname;
11
12try {
13file_put_contents($fname, 'blah');
14$a = new PharFileInfo($pname . '/oops');
15} catch (Exception $e) {
16echo $e->getMessage() . "\n";
17unlink($fname);
18}
19
20$a = new PharFileInfo(array());
21
22$a = new Phar($fname);
23$a['a'] = 'hi';
24$b = $a['a'];
25
26try {
27$a = new PharFileInfo($pname . '/oops/I/do/not/exist');
28} catch (Exception $e) {
29echo $e->getMessage() . "\n";
30}
31
32try {
33$b->__construct('oops');
34} catch (Exception $e) {
35echo $e->getMessage() . "\n";
36}
37
38try {
39$a = new PharFileInfo(__FILE__);
40} catch (Exception $e) {
41echo $e->getMessage() . "\n";
42}
43?>
44===DONE===
45--CLEAN--
46<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
47--EXPECTF--
48Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry)
49
50Warning: PharFileInfo::__construct() expects parameter 1 to be %string, array given in %spharfileinfo_construct.php on line %d
51Cannot access phar file entry '/oops/I/do/not/exist' in archive '%spharfileinfo_construct.phar'
52Cannot call constructor twice
53'%spharfileinfo_construct.php' is not a valid phar archive URL (must have at least phar://filename.phar)
54===DONE===