]> granicus.if.org Git - php/blob
38e23f706d
[php] /
1 --TEST--
2 Phar: PharFileInfo::setMetadata/delMetadata extra code coverage
3 --SKIPIF--
4 <?php if (!extension_loaded("phar")) die("skip"); ?>
5 --INI--
6 phar.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'];
18 try {
19 $phar['a']->setMetadata('hi');
20 } catch (Exception $e) {
21 echo $e->getMessage(), "\n";
22 }
23 try {
24 $phar['a']->delMetadata();
25 } catch (Exception $e) {
26 echo $e->getMessage(), "\n";
27 }
28 ini_set('phar.readonly', 1);
29 try {
30 $b->setMetadata('hi');
31 } catch (Exception $e) {
32 echo $e->getMessage(), "\n";
33 }
34 try {
35 $b->delMetadata();
36 } catch (Exception $e) {
37 echo $e->getMessage(), "\n";
38 }
39 ?>
40 --CLEAN--
41 <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
42 <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
43 --EXPECTF--
44 Phar entry is a temporary directory (not an actual entry in the archive), cannot set metadata
45 Phar entry is a temporary directory (not an actual entry in the archive), cannot delete metadata
46 Write operations disabled by the php.ini setting phar.readonly
47 Write operations disabled by the php.ini setting phar.readonly