xref: /PHP-5.4/ext/phar/tests/tar/rename.phpt (revision 16b4d8e0)
1--TEST--
2Phar: rename test tar-based
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10include dirname(__FILE__) . '/files/tarmaker.php.inc';
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
12$alias = 'phar://' . $fname;
13
14$tar = new tarmaker($fname, 'none');
15$tar->init();
16$tar->addFile('.phar/stub.php', "<?php
17Phar::mapPhar('hio');
18__HALT_COMPILER(); ?>");
19
20$files = array();
21$files['a'] = 'a';
22
23foreach ($files as $n => $file) {
24	$tar->addFile($n, $file);
25}
26
27$tar->close();
28
29include $fname;
30
31echo file_get_contents($alias . '/a') . "\n";
32rename($alias . '/a', $alias . '/b');
33echo file_get_contents($alias . '/b') . "\n";
34echo file_get_contents($alias . '/a') . "\n";
35?>
36--CLEAN--
37<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
38--EXPECTF--
39a
40a
41
42Warning: file_get_contents(phar://%srename.phar.tar/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d
43