summaryrefslogtreecommitdiff
path: root/ext/phar/tests/tar
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-01-07 17:58:31 +0000
committerGreg Beaver <cellog@php.net>2008-01-07 17:58:31 +0000
commitd9d91f424bffa0d57592d121518604d3d2dd39da (patch)
tree55f02262b639a0cdca3d61cd3bce87642d95b6f9 /ext/phar/tests/tar
parent4a59f700f1e6b1dea4740d79dce8fc97b744da65 (diff)
downloadphp-git-d9d91f424bffa0d57592d121518604d3d2dd39da.tar.gz
fp must be nulled on every write also when == phar->fp or we get stale fp and problems. add new test that unearthed this problem
Diffstat (limited to 'ext/phar/tests/tar')
-rwxr-xr-xext/phar/tests/tar/phar_begin_setstub_commit.phpt51
1 files changed, 51 insertions, 0 deletions
diff --git a/ext/phar/tests/tar/phar_begin_setstub_commit.phpt b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
new file mode 100755
index 0000000000..383e23bb4f
--- /dev/null
+++ b/ext/phar/tests/tar/phar_begin_setstub_commit.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Phar::startBuffering()/setStub()/stopBuffering() tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.tar', 0, 'brandnewphar.phar');
+var_dump($p->isTar());
+//var_dump($p->getStub());
+var_dump($p->isBuffering());
+$p->startBuffering();
+var_dump($p->isBuffering());
+$p['a.php'] = '<?php var_dump("Hello");';
+$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
+include 'phar://brandnewphar.phar/a.php';
+var_dump($p->getStub());
+$p['b.php'] = '<?php var_dump("World");';
+$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+$p->stopBuffering();
+echo "===COMMIT===\n";
+var_dump($p->isBuffering());
+include 'phar://brandnewphar.phar/a.php';
+include 'phar://brandnewphar.phar/b.php';
+var_dump($p->getStub());
+?>
+===DONE===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/brandnewphar.phar.tar');
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+string(5) "Hello"
+string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===COMMIT===
+bool(true)
+string(5) "Hello"
+string(5) "World"
+string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
+"
+===DONE===