]> granicus.if.org Git - php/commitdiff
fix fopen test problem - behavior is slightly different from PHP 5.2 -> PHP 5.3
authorGreg Beaver <cellog@php.net>
Sun, 20 Apr 2008 04:35:14 +0000 (04:35 +0000)
committerGreg Beaver <cellog@php.net>
Sun, 20 Apr 2008 04:35:14 +0000 (04:35 +0000)
now all tests pass on windows on my box

ext/phar/tests/fopen.phpt
ext/phar/tests/fopen5.2.phpt [new file with mode: 0644]

index 4184d416a227b299c1ebb17a8b2af5eb1e2d8614..5b694d6e2de4cb9a656fb8e5ffab4af02add6c57 100644 (file)
@@ -2,6 +2,7 @@
 Phar: test fopen() interception
 --SKIPIF--
 <?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (substr(phpversion(), 0, 3) == '5.2') die("skip PHP >= 5.3 required for this test");?>
 --INI--
 phar.require_hash=1
 phar.readonly=0
diff --git a/ext/phar/tests/fopen5.2.phpt b/ext/phar/tests/fopen5.2.phpt
new file mode 100644 (file)
index 0000000..aa064f1
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Phar: test fopen() interception
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip");?>
+<?php if (substr(phpversion(), 0, 3) != '5.2') die("skip PHP 5.2 required for this test");?>
+--INI--
+phar.require_hash=1
+phar.readonly=0
+--FILE--
+<?php
+Phar::interceptFileFuncs();
+$a = fopen(__FILE__, 'rb'); // this satisfies 1 line of code coverage
+fclose($a);
+$a = fopen(); // this satisfies another line of code coverage
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$a = new Phar($fname);
+$a['index.php'] = '<?php
+$a = fopen("dir/file1.txt", "r");
+echo fread($a, 2);
+fclose($a);
+$a = fopen("file1.txt", "r", true);
+echo fread($a, 2);
+fclose($a);
+$a = fopen("notfound.txt", "r", true);
+?>';
+$a['dir/file1.txt'] = 'hi';
+$a['dir/file2.txt'] = 'hi2';
+$a['dir/file3.txt'] = 'hi3';
+$a->setStub('<?php
+set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
+include "index.php";
+__HALT_COMPILER();');
+include $fname;
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+Warning: fopen() expects at least 2 parameters, 0 given in %sfopen5.2.php on line %d
+hihi
+Warning: fopen(phar://%sfopen5.2.phar.php/notfound.txt): failed to open stream: phar error: "notfound.txt" is not a file in phar "%sfopen5.2.phar.php" in phar://%sfopen5.2.phar.php/index.php on line %d
+===DONE===
\ No newline at end of file