1--TEST--
2Phar: PharFileInfo::setMetadata/delMetadata extra code coverage
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
10$pname = 'phar://' . $fname;
11
12$phar = new Phar($fname);
13
14$phar['a/b'] = 'hi there';
15$tar = $phar->convertToData(Phar::TAR);
16
17$b = $phar['a/b'];
18try {
19$phar['a']->setMetadata('hi');
20} catch (Exception $e) {
21echo $e->getMessage(), "\n";
22}
23try {
24$phar['a']->delMetadata();
25} catch (Exception $e) {
26echo $e->getMessage(), "\n";
27}
28ini_set('phar.readonly', 1);
29try {
30$b->setMetadata('hi');
31} catch (Exception $e) {
32echo $e->getMessage(), "\n";
33}
34try {
35$b->delMetadata();
36} catch (Exception $e) {
37echo $e->getMessage(), "\n";
38}
39ini_set('phar.readonly', 0);
40$b->setMetadata(1,2,3);
41?>
42===DONE===
43--CLEAN--
44<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
45<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
46--EXPECTF--
47Phar entry is a temporary directory (not an actual entry in the archive), cannot set metadata
48Phar entry is a temporary directory (not an actual entry in the archive), cannot delete metadata
49Write operations disabled by the php.ini setting phar.readonly
50Write operations disabled by the php.ini setting phar.readonly
51
52Warning: PharFileInfo::setMetadata() expects exactly 1 parameter, 3 given in %spharfileinfo_setmetadata.php on line %d
53===DONE===
54