1--TEST--
2Phar::isWriteable
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
11$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
12$pname = 'phar://hio';
13$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
14
15$files = array();
16$files['a.php']   = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
17$files['dir/'] = '';
18$hasdir = 1;
19include 'files/phar_test.inc';
20$a = new Phar($fname);
21$b = new PharData($fname2);
22$b['test'] = 'hi';
23
24var_dump($a['a.php']->isWritable());
25var_dump($a['a.php']->isReadable());
26$a['a.php']->chmod(000);
27var_dump($a['a.php']->isWritable());
28var_dump($a['a.php']->isReadable());
29$a['a.php']->chmod(0666);
30var_dump($a['a.php']->isWritable());
31var_dump($a['a.php']->isReadable());
32ini_set('phar.readonly',1);
33clearstatcache();
34var_dump($a['a.php']->isWritable());
35var_dump($a['a.php']->isReadable());
36ini_set('phar.readonly',0);
37clearstatcache();
38var_dump($a['a.php']->isWritable());
39var_dump($a['a.php']->isReadable());
40?>
41archive
42<?php
43ini_set('phar.readonly',0);
44$p = new Phar('doesnotexisthere.phar');
45var_dump($p->isWritable());
46clearstatcache();
47var_dump($a->isWritable());
48var_dump($b->isWritable());
49ini_set('phar.readonly',1);
50clearstatcache();
51var_dump($a->isWritable());
52var_dump($b->isWritable());
53chmod($fname2, 000);
54clearstatcache();
55var_dump($a->isWritable());
56var_dump($b->isWritable());
57chmod($fname2, 0666);
58?>
59===DONE===
60--CLEAN--
61<?php
62unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
63unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
64?>
65--EXPECT--
66bool(true)
67bool(true)
68bool(false)
69bool(false)
70bool(true)
71bool(true)
72bool(false)
73bool(true)
74bool(true)
75bool(true)
76archive
77bool(true)
78bool(true)
79bool(true)
80bool(false)
81bool(true)
82bool(false)
83bool(false)
84===DONE===
85