~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/phar/tests/zip/open_for_write_newfile_c.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Phar: fopen a .phar for writing (new file) zip-based
 
3
--SKIPIF--
 
4
<?php
 
5
if (!extension_loaded("phar")) die("skip");
 
6
if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
 
7
?>
 
8
--INI--
 
9
phar.readonly=0
 
10
phar.require_hash=0
 
11
--FILE--
 
12
<?php
 
13
 
 
14
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
 
15
$alias = 'phar://' . $fname;
 
16
 
 
17
$phar = new Phar($fname);
 
18
$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
19
 
 
20
$files = array();
 
21
 
 
22
$files['a.php'] = '<?php echo "This is a\n"; ?>';
 
23
$files['b.php'] = '<?php echo "This is b\n"; ?>';
 
24
$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
 
25
 
 
26
foreach ($files as $n => $file) {
 
27
        $phar[$n] = $file;
 
28
}
 
29
$phar->stopBuffering();
 
30
 
 
31
ini_set('phar.readonly', 1);
 
32
 
 
33
$fp = fopen($alias . '/b/new.php', 'wb');
 
34
fwrite($fp, b'extra');
 
35
fclose($fp);
 
36
 
 
37
include $alias . '/b/c.php';
 
38
include $alias . '/b/new.php';
 
39
?>
 
40
 
 
41
===DONE===
 
42
--CLEAN--
 
43
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 
44
--EXPECTF--
 
45
 
 
46
Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
 
47
 
 
48
Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 
49
 
 
50
Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 
51
This is b/c
 
52
 
 
53
Warning: include(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.zip" in %sopen_for_write_newfile_c.php on line %d
 
54
 
 
55
Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
 
56
 
 
57
===DONE===
 
 
b'\\ No newline at end of file'