xref: /PHP-5.3/ext/phar/tests/test_unset.phpt (revision 16b4d8e0)
1--TEST--
2Phar: ensure unset() works properly on a non-flushed phar archive
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.php';
10$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
11
12if (file_exists($fname)) unlink($fname);
13if (file_exists($fname2)) unlink($fname2);
14
15$phar = new Phar($fname); // no entries, never flushed
16$phar->setAlias('first');
17$phar->setMetadata('hi');
18unset($phar);
19
20$phar = new Phar($fname2);
21$phar['b'] = 'whatever'; // flushed
22try {
23   $phar->setAlias('first');
24} catch(Exception $e) {
25   echo $e->getMessage()."\n";
26}
27
28$phar = new Phar($fname);
29var_dump($phar->getMetadata());
30var_dump($phar->getAlias());
31var_dump(file_exists($fname));
32
33?>
34===DONE===
35--CLEAN--
36<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
37<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php'); ?>
38--EXPECTF--
39NULL
40string(%d) "%stest_unset.phar.php"
41bool(false)
42===DONE===