]> granicus.if.org Git - php/commitdiff
add complete tests verifying copy-on-write for cached phars
authorGreg Beaver <cellog@php.net>
Mon, 13 Oct 2008 04:21:09 +0000 (04:21 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 13 Oct 2008 04:21:09 +0000 (04:21 +0000)
65 files changed:
ext/phar/tests/cache_list/copyonwrite10.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite11.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite12.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite13.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite14.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite15.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite16.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite17.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite18.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite19.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite20.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite21.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite22.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite23.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite24.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite4.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite4a.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite5.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite6.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite7.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite8.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/copyonwrite9.phar.phpt [new file with mode: 0644]
ext/phar/tests/cache_list/files/write10.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write10.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write11.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write11.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write12.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write12.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write13.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write13.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write14.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write14.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write15.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write15.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write16.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write16.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write17.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write17.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write18.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write18.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write19.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write19.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write20.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write20.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write21.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write21.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write22.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write22.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write23.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write23.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write24.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write24.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write3.phar
ext/phar/tests/cache_list/files/write4.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write4.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write5.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write5.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write6.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write6.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write7.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write7.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write8.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write8.phar.inc [new file with mode: 0644]
ext/phar/tests/cache_list/files/write9.phar [new file with mode: 0644]
ext/phar/tests/cache_list/files/write9.phar.inc [new file with mode: 0644]

diff --git a/ext/phar/tests/cache_list/copyonwrite10.phar.phpt b/ext/phar/tests/cache_list/copyonwrite10.phar.phpt
new file mode 100644 (file)
index 0000000..3d5b7fe
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Phar: copy-on-write test 10 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite10.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write10.phar
+--EXPECTF--
+string(214) "<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$a = fopen("phar://" . __FILE__ . "/test.txt", "r");
+$p->setStub($a);
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER(); ?>
+"
+<?php __HALT_COMPILER(); ?>
+
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite11.phar.phpt b/ext/phar/tests/cache_list/copyonwrite11.phar.phpt
new file mode 100644 (file)
index 0000000..6538816
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Phar: copy-on-write test 11 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite11.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write11.phar
+--EXPECTF--
+string(174) "<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setDefaultStub();
+echo strlen($p2->getStub()),"\n";
+echo "ok\n";
+__HALT_COMPILER(); ?>
+"
+6685
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite12.phar.phpt b/ext/phar/tests/cache_list/copyonwrite12.phar.phpt
new file mode 100644 (file)
index 0000000..40b5441
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Phar: copy-on-write test 12 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite12.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write12.phar
+--EXPECTF--
+array(2) {
+  ["hash"]=>
+  string(40) "0163F471460EA74F7636268D28289BF5A1E8BD72"
+  ["hash_type"]=>
+  string(5) "SHA-1"
+}
+array(2) {
+  ["hash"]=>
+  string(32) "%s"
+  ["hash_type"]=>
+  string(3) "MD5"
+}
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite13.phar.phpt b/ext/phar/tests/cache_list/copyonwrite13.phar.phpt
new file mode 100644 (file)
index 0000000..fc47174
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 13 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite13.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write13.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite14.phar.phpt b/ext/phar/tests/cache_list/copyonwrite14.phar.phpt
new file mode 100644 (file)
index 0000000..11201ac
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 14 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite14.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write14.phar
+--EXPECTF--
+bool(true)
+bool(false)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite15.phar.phpt b/ext/phar/tests/cache_list/copyonwrite15.phar.phpt
new file mode 100644 (file)
index 0000000..6e46289
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 15 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite15.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write15.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite16.phar.phpt b/ext/phar/tests/cache_list/copyonwrite16.phar.phpt
new file mode 100644 (file)
index 0000000..f17784c
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 16 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite16.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write16.phar
+--EXPECTF--
+bool(true)
+bool(false)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite17.phar.phpt b/ext/phar/tests/cache_list/copyonwrite17.phar.phpt
new file mode 100644 (file)
index 0000000..6e13088
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 17 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite17.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write17.phar
+--EXPECTF--
+NULL
+string(2) "hi"
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite18.phar.phpt b/ext/phar/tests/cache_list/copyonwrite18.phar.phpt
new file mode 100644 (file)
index 0000000..3e65f5a
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 18 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite18.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write18.phar
+--EXPECTF--
+100666
+100444
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite19.phar.phpt b/ext/phar/tests/cache_list/copyonwrite19.phar.phpt
new file mode 100644 (file)
index 0000000..4870550
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 19 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite19.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write19.phar
+--EXPECTF--
+string(2) "hi"
+string(3) "hi2"
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite20.phar.phpt b/ext/phar/tests/cache_list/copyonwrite20.phar.phpt
new file mode 100644 (file)
index 0000000..acce574
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 20 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite20.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write20.phar
+--EXPECTF--
+string(2) "hi"
+NULL
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite21.phar.phpt b/ext/phar/tests/cache_list/copyonwrite21.phar.phpt
new file mode 100644 (file)
index 0000000..8960ea7
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 21 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite21.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write21.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite22.phar.phpt b/ext/phar/tests/cache_list/copyonwrite22.phar.phpt
new file mode 100644 (file)
index 0000000..7cba216
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 22 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite22.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write22.phar
+--EXPECTF--
+bool(true)
+bool(false)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite23.phar.phpt b/ext/phar/tests/cache_list/copyonwrite23.phar.phpt
new file mode 100644 (file)
index 0000000..292e5af
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Phar: copy-on-write test 23 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite23.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write23.phar
+--EXPECTF--
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite24.phar.phpt b/ext/phar/tests/cache_list/copyonwrite24.phar.phpt
new file mode 100644 (file)
index 0000000..69197f2
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 24 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite24.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib extension"); ?>
+--FILE_EXTERNAL--
+files/write24.phar
+--EXPECTF--
+bool(false)
+bool(true)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite4.phar.phpt b/ext/phar/tests/cache_list/copyonwrite4.phar.phpt
new file mode 100644 (file)
index 0000000..20ff78e
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Phar: copy-on-write test 4 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite4.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write4.phar
+--EXPECT--
+bool(false)
+bool(true)
+string(2) "hi"
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite4a.phpt b/ext/phar/tests/cache_list/copyonwrite4a.phpt
new file mode 100644 (file)
index 0000000..1945e31
--- /dev/null
@@ -0,0 +1,20 @@
+--TEST--
+Phar: copy-on-write test 4a [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite4.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(file_exists('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt'));
+Phar::mount('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt', 'phar://' . dirname(__FILE__) . '/files/write4.phar/tobemounted');
+var_dump(file_exists('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt'), file_get_contents('phar://' . dirname(__FILE__) . '/files/write4.phar/testit.txt'));
+?>
+===DONE===
+--EXPECT--
+bool(false)
+bool(true)
+string(2) "hi"
+===DONE===
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite5.phar.phpt b/ext/phar/tests/cache_list/copyonwrite5.phar.phpt
new file mode 100644 (file)
index 0000000..89990a7
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Phar: copy-on-write test 5 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite5.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write5.phar
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/copyonwrite5/file1');
+unlink(dirname(__FILE__) . '/copyonwrite5/file2');
+rmdir(dirname(__FILE__) . '/copyonwrite5');
+?>
+--EXPECTF--
+array(2) {
+  ["file1"]=>
+  string(%d) "%sfile1"
+  ["file2"]=>
+  string(%d) "%sfile2"
+}
+phar://%scopyonwrite5.phar.php%cfile1 file1
+phar://%scopyonwrite5.phar.php%cfile2 file2
+phar://%scopyonwrite5.phar.php%chi hi
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite6.phar.phpt b/ext/phar/tests/cache_list/copyonwrite6.phar.phpt
new file mode 100644 (file)
index 0000000..083a141
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Phar: copy-on-write test 6 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite6.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write6.phar
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/copyonwrite6/file1');
+unlink(dirname(__FILE__) . '/copyonwrite6/file2');
+rmdir(dirname(__FILE__) . '/copyonwrite6');
+?>
+--EXPECTF--
+array(2) {
+  ["file1"]=>
+  string(%d) "%sfile1"
+  ["file2"]=>
+  string(%d) "%sfile2"
+}
+phar://%scopyonwrite6.phar.php%cfile1 file1
+phar://%scopyonwrite6.phar.php%cfile2 file2
+phar://%scopyonwrite6.phar.php%chi hi
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite7.phar.phpt b/ext/phar/tests/cache_list/copyonwrite7.phar.phpt
new file mode 100644 (file)
index 0000000..d6faded
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 7 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite7.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write7.phar
+--EXPECT--
+bool(true)
+bool(false)
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite8.phar.phpt b/ext/phar/tests/cache_list/copyonwrite8.phar.phpt
new file mode 100644 (file)
index 0000000..7217d33
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Phar: copy-on-write test 8 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite8.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write8.phar
+--EXPECTF--
+string(%s) "%scopyonwrite8.phar.php"
+hi
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/copyonwrite9.phar.phpt b/ext/phar/tests/cache_list/copyonwrite9.phar.phpt
new file mode 100644 (file)
index 0000000..ffda956
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Phar: copy-on-write test 9 [cache_list]
+--INI--
+default_charset=UTF-8
+phar.cache_list={PWD}/copyonwrite9.phar.php
+phar.readonly=0
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE_EXTERNAL--
+files/write9.phar
+--EXPECTF--
+string(188) "<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setStub("<?php __HALT"."_COMPILER();");
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER(); ?>
+"
+<?php __HALT_COMPILER(); ?>
+
+ok
\ No newline at end of file
diff --git a/ext/phar/tests/cache_list/files/write10.phar b/ext/phar/tests/cache_list/files/write10.phar
new file mode 100644 (file)
index 0000000..473f0a1
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write10.phar differ
diff --git a/ext/phar/tests/cache_list/files/write10.phar.inc b/ext/phar/tests/cache_list/files/write10.phar.inc
new file mode 100644 (file)
index 0000000..a23b5e5
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write10.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$a = fopen("phar://" . __FILE__ . "/test.txt", "r");
+$p->setStub($a);
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write11.phar b/ext/phar/tests/cache_list/files/write11.phar
new file mode 100644 (file)
index 0000000..bb8d33f
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write11.phar differ
diff --git a/ext/phar/tests/cache_list/files/write11.phar.inc b/ext/phar/tests/cache_list/files/write11.phar.inc
new file mode 100644 (file)
index 0000000..d255264
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write11.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setDefaultStub();
+echo strlen($p2->getStub()),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write12.phar b/ext/phar/tests/cache_list/files/write12.phar
new file mode 100644 (file)
index 0000000..bff1456
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write12.phar differ
diff --git a/ext/phar/tests/cache_list/files/write12.phar.inc b/ext/phar/tests/cache_list/files/write12.phar.inc
new file mode 100644 (file)
index 0000000..f0c01eb
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write12.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getSignature());
+$p2 = new Phar(__FILE__);
+$p->setSignatureAlgorithm(Phar::MD5);
+var_dump($p->getSignature());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write13.phar b/ext/phar/tests/cache_list/files/write13.phar
new file mode 100644 (file)
index 0000000..46ca14d
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write13.phar differ
diff --git a/ext/phar/tests/cache_list/files/write13.phar.inc b/ext/phar/tests/cache_list/files/write13.phar.inc
new file mode 100644 (file)
index 0000000..e8b6f33
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write13.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p2 = new Phar(__FILE__);
+$p->compressFiles(Phar::GZ);
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write14.phar b/ext/phar/tests/cache_list/files/write14.phar
new file mode 100644 (file)
index 0000000..4482752
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write14.phar differ
diff --git a/ext/phar/tests/cache_list/files/write14.phar.inc b/ext/phar/tests/cache_list/files/write14.phar.inc
new file mode 100644 (file)
index 0000000..c2b0448
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write14.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p2 = new Phar(__FILE__);
+$p->decompressFiles();
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar->compressFiles(Phar::GZ);
+?>
diff --git a/ext/phar/tests/cache_list/files/write15.phar b/ext/phar/tests/cache_list/files/write15.phar
new file mode 100644 (file)
index 0000000..c6190b7
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write15.phar differ
diff --git a/ext/phar/tests/cache_list/files/write15.phar.inc b/ext/phar/tests/cache_list/files/write15.phar.inc
new file mode 100644 (file)
index 0000000..d30f6c8
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write15.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["copied"]));
+$p->copy("test.txt","copied");
+var_dump(isset($p["copied"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write16.phar b/ext/phar/tests/cache_list/files/write16.phar
new file mode 100644 (file)
index 0000000..05106ea
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write16.phar differ
diff --git a/ext/phar/tests/cache_list/files/write16.phar.inc b/ext/phar/tests/cache_list/files/write16.phar.inc
new file mode 100644 (file)
index 0000000..b7a1b38
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write16.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["test.txt"]));
+unset($p["test.txt"]);
+var_dump(isset($p["test.txt"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar['test2.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write17.phar b/ext/phar/tests/cache_list/files/write17.phar
new file mode 100644 (file)
index 0000000..52ddb5e
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write17.phar differ
diff --git a/ext/phar/tests/cache_list/files/write17.phar.inc b/ext/phar/tests/cache_list/files/write17.phar.inc
new file mode 100644 (file)
index 0000000..47f5ea3
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write17.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getMetadata());
+$p->setMetadata("hi");
+var_dump($p->getMetadata());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write18.phar b/ext/phar/tests/cache_list/files/write18.phar
new file mode 100644 (file)
index 0000000..3fc9fe1
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write18.phar differ
diff --git a/ext/phar/tests/cache_list/files/write18.phar.inc b/ext/phar/tests/cache_list/files/write18.phar.inc
new file mode 100644 (file)
index 0000000..fca867d
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write18.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+echo decoct(fileperms("phar://" . __FILE__ . "/test.txt")),"\n";
+$p["test.txt"]->chmod(0444);
+echo decoct(fileperms("phar://" . __FILE__ . "/test.txt")),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar["test.txt"]->chmod(0666);
+?>
diff --git a/ext/phar/tests/cache_list/files/write19.phar b/ext/phar/tests/cache_list/files/write19.phar
new file mode 100644 (file)
index 0000000..9e8b7ee
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write19.phar differ
diff --git a/ext/phar/tests/cache_list/files/write19.phar.inc b/ext/phar/tests/cache_list/files/write19.phar.inc
new file mode 100644 (file)
index 0000000..55115ad
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write19.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->getMetadata());
+$p["test.txt"]->setMetadata("hi2");
+var_dump($p["test.txt"]->getMetadata());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar["test.txt"]->setMetadata("hi");
+?>
diff --git a/ext/phar/tests/cache_list/files/write20.phar b/ext/phar/tests/cache_list/files/write20.phar
new file mode 100644 (file)
index 0000000..6109264
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write20.phar differ
diff --git a/ext/phar/tests/cache_list/files/write20.phar.inc b/ext/phar/tests/cache_list/files/write20.phar.inc
new file mode 100644 (file)
index 0000000..d356bfb
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write20.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->getMetadata());
+$p["test.txt"]->delMetadata();
+var_dump($p["test.txt"]->getMetadata());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar["test.txt"]->setMetadata("hi");
+?>
diff --git a/ext/phar/tests/cache_list/files/write21.phar b/ext/phar/tests/cache_list/files/write21.phar
new file mode 100644 (file)
index 0000000..fad2165
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write21.phar differ
diff --git a/ext/phar/tests/cache_list/files/write21.phar.inc b/ext/phar/tests/cache_list/files/write21.phar.inc
new file mode 100644 (file)
index 0000000..79bfb20
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write21.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p["test.txt"]->compress(Phar::GZ);
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write22.phar b/ext/phar/tests/cache_list/files/write22.phar
new file mode 100644 (file)
index 0000000..c3c5ce1
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write22.phar differ
diff --git a/ext/phar/tests/cache_list/files/write22.phar.inc b/ext/phar/tests/cache_list/files/write22.phar.inc
new file mode 100644 (file)
index 0000000..861cabb
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write22.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p["test.txt"]->isCompressed());
+$p["test.txt"]->decompress();
+var_dump($p["test.txt"]->isCompressed());
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+$phar['test.txt']->compress(Phar::GZ);
+?>
diff --git a/ext/phar/tests/cache_list/files/write23.phar b/ext/phar/tests/cache_list/files/write23.phar
new file mode 100644 (file)
index 0000000..2246f61
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write23.phar differ
diff --git a/ext/phar/tests/cache_list/files/write23.phar.inc b/ext/phar/tests/cache_list/files/write23.phar.inc
new file mode 100644 (file)
index 0000000..ac92a85
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write23.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["test.txt"]), isset($p["newname"]));
+rename("phar://" . __FILE__ . "/test.txt", "phar://" . __FILE__ . "/newname");
+var_dump(isset($p["test.txt"]), isset($p["newname"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
diff --git a/ext/phar/tests/cache_list/files/write24.phar b/ext/phar/tests/cache_list/files/write24.phar
new file mode 100644 (file)
index 0000000..d726cee
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write24.phar differ
diff --git a/ext/phar/tests/cache_list/files/write24.phar.inc b/ext/phar/tests/cache_list/files/write24.phar.inc
new file mode 100644 (file)
index 0000000..ac96731
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write24.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(isset($p["newname"]));
+$fp = fopen("phar://" . __FILE__ . "/newname", "w");
+fwrite($fp, "hi");
+fclose($fp);
+var_dump(isset($p["newname"]));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "<?php __HALT"."_COMPILER();";
+?>
index c5be7daceb9b4c018e3dccf8117b6bfee2009e06..5ce4a95f79b7011a6766c6ce4a07d26e1093d27a 100644 (file)
Binary files a/ext/phar/tests/cache_list/files/write3.phar and b/ext/phar/tests/cache_list/files/write3.phar differ
diff --git a/ext/phar/tests/cache_list/files/write4.phar b/ext/phar/tests/cache_list/files/write4.phar
new file mode 100644 (file)
index 0000000..c267bab
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write4.phar differ
diff --git a/ext/phar/tests/cache_list/files/write4.phar.inc b/ext/phar/tests/cache_list/files/write4.phar.inc
new file mode 100644 (file)
index 0000000..5b476ed
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write4.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
+clearstatcache();
+Phar::mount("test.txt", "phar://" . __FILE__ . "/tobemounted");
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"), file_get_contents("phar://" . __FILE__ . "/test.txt"));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['tobemounted'] = "hi";
+?>
diff --git a/ext/phar/tests/cache_list/files/write5.phar b/ext/phar/tests/cache_list/files/write5.phar
new file mode 100644 (file)
index 0000000..b3a318b
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write5.phar differ
diff --git a/ext/phar/tests/cache_list/files/write5.phar.inc b/ext/phar/tests/cache_list/files/write5.phar.inc
new file mode 100644 (file)
index 0000000..04a4dfe
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write5.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$phar = new Phar(__FILE__);
+$d = dirname(__FILE__) . "/copyonwrite5";
+mkdir($d);
+file_put_contents($d . "/file1", "file1\n");
+file_put_contents($d . "/file2", "file2\n");
+var_dump($phar->buildFromDirectory($d));
+$phar2 = new Phar(__FILE__);
+$arr = array();
+foreach ($phar2 as $name => $file) {
+       $arr[$name] = $file->getContent();
+}
+asort($arr);
+foreach ($arr as $name => $content) {
+       echo $name, " ", $content;
+}
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['hi'] = "hi\n";
+?>
diff --git a/ext/phar/tests/cache_list/files/write6.phar b/ext/phar/tests/cache_list/files/write6.phar
new file mode 100644 (file)
index 0000000..68a4a86
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write6.phar differ
diff --git a/ext/phar/tests/cache_list/files/write6.phar.inc b/ext/phar/tests/cache_list/files/write6.phar.inc
new file mode 100644 (file)
index 0000000..4010b60
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write6.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$phar = new Phar(__FILE__);
+$d = dirname(__FILE__) . "/copyonwrite6";
+mkdir($d);
+file_put_contents($d . "/file1", "file1\n");
+file_put_contents($d . "/file2", "file2\n");
+var_dump($phar->buildFromIterator(new RecursiveDirectoryIterator($d),$d));
+$phar2 = new Phar(__FILE__);
+$arr = array();
+foreach ($phar2 as $name => $file) {
+       $arr[$name] = $file->getContent();
+}
+asort($arr);
+foreach ($arr as $name => $content) {
+       echo $name, " ", $content;
+}
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['hi'] = "hi\n";
+?>
diff --git a/ext/phar/tests/cache_list/files/write7.phar b/ext/phar/tests/cache_list/files/write7.phar
new file mode 100644 (file)
index 0000000..e5854ec
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write7.phar differ
diff --git a/ext/phar/tests/cache_list/files/write7.phar.inc b/ext/phar/tests/cache_list/files/write7.phar.inc
new file mode 100644 (file)
index 0000000..ef5b8b2
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write7.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
+$p->delete("test.txt");
+clearstatcache();
+var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "hi
+";
+?>
diff --git a/ext/phar/tests/cache_list/files/write8.phar b/ext/phar/tests/cache_list/files/write8.phar
new file mode 100644 (file)
index 0000000..d5d63be
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write8.phar differ
diff --git a/ext/phar/tests/cache_list/files/write8.phar.inc b/ext/phar/tests/cache_list/files/write8.phar.inc
new file mode 100644 (file)
index 0000000..2b733a7
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write8.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getAlias());
+$p2 = new Phar(__FILE__);
+$p->setAlias("hi");
+echo $p2->getAlias(),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "hi
+";
+?>
diff --git a/ext/phar/tests/cache_list/files/write9.phar b/ext/phar/tests/cache_list/files/write9.phar
new file mode 100644 (file)
index 0000000..c012c17
Binary files /dev/null and b/ext/phar/tests/cache_list/files/write9.phar differ
diff --git a/ext/phar/tests/cache_list/files/write9.phar.inc b/ext/phar/tests/cache_list/files/write9.phar.inc
new file mode 100644 (file)
index 0000000..ed3e681
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+$fname = dirname(__FILE__) . '/write9.phar';
+@unlink($fname);
+
+$phar = new Phar($fname);
+$phar->setStub('<?php
+$p = new Phar(__FILE__);
+var_dump($p->getStub());
+$p2 = new Phar(__FILE__);
+$p->setStub("<?php __HALT"."_COMPILER();");
+echo $p2->getStub(),"\n";
+echo "ok\n";
+__HALT_COMPILER();
+?>');
+$phar['test.txt'] = "hi
+";
+?>