]> granicus.if.org Git - php/commitdiff
fix tests
authorZoe Slattery <zoe@php.net>
Fri, 23 Jan 2009 09:21:25 +0000 (09:21 +0000)
committerZoe Slattery <zoe@php.net>
Fri, 23 Jan 2009 09:21:25 +0000 (09:21 +0000)
ext/standard/tests/file/fopen_variation17.phpt
ext/standard/tests/file/fopen_variation5.phpt
ext/standard/tests/file/fopen_variation7.phpt
ext/standard/tests/file/fopen_variation8.phpt
ext/standard/tests/file/fopen_variation9.phpt

index a565d7dffa132fc309b6f2d79f92862cac0e368e..75f24b3553af0a613dae3c6ed075007824b2645b 100644 (file)
@@ -2,8 +2,6 @@
 Test fopen() function : variation: use include path create and read a file (relative) 
 --CREDITS--
 Dave Kelsey <d_kelsey@uk.ibm.com>
---XFAIL--
-Bug #46680
 --FILE--
 <?php
 /* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
@@ -14,14 +12,14 @@ Bug #46680
 
 require_once('fopen_include_path.inc');
 
-echo "*** Testing fopen() : variation ***\n";
-$thisTestDir = "fopenVariation17.dir";
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
 mkdir($thisTestDir);
 chdir($thisTestDir);
 
 $newpath = create_include_path();
 set_include_path($newpath);
 runtest();
+
 $newpath = generate_next_path();
 set_include_path($newpath);
 runtest();
@@ -37,13 +35,14 @@ function runtest() {
     $extraDir = "extraDir";
 
     mkdir($dir1.'/'.$extraDir);
+    mkdir($extraDir);
     
-       $tmpfile = $extraDir.'/fopen_variation17.tmp';
+       $tmpfile = $extraDir.'/ basename(__FILE__, ".php") . ".tmp"';
        $h = fopen($tmpfile, "w+", true);
-       fwrite($h, "This is the test file");
+       fwrite($h, (binary) "This is the test file");
        fclose($h);
        
-       $h = fopen($dir1.'/'.$tmpfile, "r");
+       $h = @fopen($dir1.'/'.$tmpfile, "r");
        if ($h === false) {
           echo "Not created in dir1\n";
        }
@@ -57,19 +56,19 @@ function runtest() {
           echo "could not find file for reading\n";
        }
        else {
-          echo "found file again in dir1\n";
+          echo "found file for reading\n";
           fclose($h);
        }
        
-       unlink($dir1.'/'.$tmpfile);   
-    rmdir($dir1.'/'.$extraDir);        
+       unlink($tmpfile);   
+        rmdir($dir1.'/'.$extraDir);    
+        rmdir($extraDir);      
 }
 ?>
 ===DONE===
 --EXPECT--
-*** Testing fopen() : variation ***
-created in dir1
-found file again in dir1
-created in dir1
-found file again in dir1
+Not created in dir1
+found file for reading
+Not created in dir1
+found file for reading
 ===DONE===
index 9a47708f3e706ec8234314e4732f37663344ba49..975560f5ce5d5c66a744c92de343c8382cbf4a00 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Test fopen() function : variation: use include path and stream context (absolute directories in path)
---XFAIL--
-Pending completion of Unicode streams
 --CREDITS--
 Dave Kelsey <d_kelsey@uk.ibm.com>
 --FILE--
@@ -14,14 +12,13 @@ Dave Kelsey <d_kelsey@uk.ibm.com>
 
 
 
-echo "*** Testing fopen() : variation ***\n";
 //create the include directory structure
-$thisTestDir = "fopenVariation5.dir";
+$thisTestDir =  basename(__FILE__, ".php") . ".dir";
 mkdir($thisTestDir);
 chdir($thisTestDir);
 
 $workingDir = "workdir";
-$filename = "afile.txt";
+$filename = basename(__FILE__, ".php") . ".tmp";
 $scriptDir = dirname(__FILE__);
 $baseDir = getcwd();
 $secondFile = $baseDir."/dir2/".$filename;
@@ -66,7 +63,7 @@ function test_fopen($mode) {
    
    // create a file in the middle directory
    $h = fopen($secondFile, "w");
-   fwrite($h, "in dir2");
+   fwrite($h, (binary) "in dir2");
    fclose($h);
 
    echo "\n** testing with mode=$mode **\n";
@@ -78,7 +75,7 @@ function test_fopen($mode) {
 
    //create a file in dir1
    $h = fopen($firstFile, "w");
-   fwrite($h, "in dir1");
+   fwrite($h, (binary) "in dir1");
    fclose($h);
    
    //should now read dir1 file
@@ -89,7 +86,7 @@ function test_fopen($mode) {
    
    // create a file in working directory
    $h = fopen($filename, "w");
-   fwrite($h, "in working dir");
+   fwrite($h, (binary) "in working dir");
    fclose($h);
    
    //should still read dir1 file
@@ -101,7 +98,7 @@ function test_fopen($mode) {
    unlink($firstFile);
    unlink($secondFile);
    
-   //should fail to read the file
+   //should read the file in working dir
    $h = fopen($filename, $mode, true);
    fpassthru($h);
    fclose($h);
@@ -109,7 +106,7 @@ function test_fopen($mode) {
    
    // create a file in the script directory
    $h = fopen($scriptFile, "w");
-   fwrite($h, "in script dir");
+   fwrite($h, (binary) "in script dir");
    fclose($h);
    
    //should read the file in script dir
@@ -127,7 +124,6 @@ function test_fopen($mode) {
 ?>
 ===DONE===
 --EXPECTF--
-*** Testing fopen() : variation ***
 
 --- testing include path ---
 
@@ -135,39 +131,21 @@ function test_fopen($mode) {
 in dir2
 in dir1
 in dir1
-
-Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
-
-Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
-
+in working dir
 in script dir
 
 ** testing with mode=r+ **
 in dir2
 in dir1
 in dir1
-
-Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
-
-Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
-
+in working dir
 in script dir
 
 ** testing with mode=rt **
 in dir2
 in dir1
 in dir1
-
-Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
-
-Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
-
+in working dir
 in script dir
 ===DONE===
 
index 08ba2d61b8969394f948bf7a425b0a99fbb7758c..13f075cfff71837b4ce128aea09491f7cbbe9cc8 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Test fopen() function : variation: use include path create a file (relative)
---XFAIL--
-Pending completion of Unicode streams
 --CREDITS--
 Dave Kelsey <d_kelsey@uk.ibm.com>
 --FILE--
@@ -14,8 +12,7 @@ Dave Kelsey <d_kelsey@uk.ibm.com>
 
 require_once('fopen_include_path.inc');
 
-echo "*** Testing fopen() : variation ***\n";
-$thisTestDir = "fopenVariation7.dir";
+$thisTestDir =  basename(__FILE__, ".php") . ".dir";
 mkdir($thisTestDir);
 chdir($thisTestDir);
 
@@ -33,9 +30,9 @@ rmdir($thisTestDir);
 
 function runtest() {
     global $dir1;
-       $tmpfile = 'fopen_variation7.tmp';
+       $tmpfile =  basename(__FILE__, ".php") . ".tmp";
        $h = fopen($tmpfile, "w", true);
-       fwrite($h, "This is the test file");
+       fwrite($h, (binary)"This is the test file");
        fclose($h);
        
        
@@ -49,7 +46,7 @@ function runtest() {
           unlink($tmpfile);
        }
        
-       $h = fopen($dir1.'/'.$tmpfile, "r");
+       $h = @fopen($dir1.'/'.$tmpfile, "r");
        if ($h === false) {
           echo "Not created in dir1\n";
        }
@@ -62,9 +59,8 @@ function runtest() {
 ?>
 ===DONE===
 --EXPECT--
-*** Testing fopen() : variation ***
-Not created in working dir
-created in dir1
-Not created in working dir
-created in dir1
+created in working dir
+Not created in dir1
+created in working dir
+Not created in dir1
 ===DONE===
index b142641adc3086eac562b3a7c1cc6b2c2f322684..dd95014ff3100b77ffc189e1558428b437bcebf8 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Test fopen() function : variation: use include path and stream context (relative directories in path)
---XFAIL--
-Pending completion of Unicode streams
 --CREDITS--
 Dave Kelsey <d_kelsey@uk.ibm.com>
 --FILE--
@@ -14,14 +12,13 @@ Dave Kelsey <d_kelsey@uk.ibm.com>
 
 
 
-echo "*** Testing fopen() : variation ***\n";
-$thisTestDir = "fopenVariation8.dir";
+$thisTestDir =  basename(__FILE__, ".php") . ".dir";
 mkdir($thisTestDir);
 chdir($thisTestDir);
 
 //create the include directory structure
 $workingDir = "workdir";
-$filename = "afile.txt";
+$filename =  basename(__FILE__, ".php") . ".tmp";
 $scriptDir = dirname(__FILE__);
 $baseDir = getcwd();
 $secondFile = $baseDir."/dir2/".$filename;
@@ -65,7 +62,7 @@ function test_fopen($mode) {
    
    // create a file in the middle directory
    $h = fopen($secondFile, "w");
-   fwrite($h, "in dir2");
+   fwrite($h, (binary) "in dir2");
    fclose($h);
 
    echo "\n** testing with mode=$mode **\n";
@@ -77,7 +74,7 @@ function test_fopen($mode) {
 
    //create a file in dir1
    $h = fopen($firstFile, "w");
-   fwrite($h, "in dir1");
+   fwrite($h, (binary) "in dir1");
    fclose($h);
    
    //should now read dir1 file
@@ -88,10 +85,10 @@ function test_fopen($mode) {
    
    // create a file in working directory
    $h = fopen($filename, "w");
-   fwrite($h, "in working dir");
+   fwrite($h, (binary) "in working dir");
    fclose($h);
    
-   //should still read dir1 file
+   //should read the dir1 file
    $h = fopen($filename, $mode, true);
    fpassthru($h);
    fclose($h);
@@ -100,7 +97,7 @@ function test_fopen($mode) {
    unlink($firstFile);
    unlink($secondFile);
    
-   //should fail to read the file
+   //should read the working dir file
    $h = fopen($filename, $mode, true);
    fpassthru($h);
    fclose($h);
@@ -108,7 +105,7 @@ function test_fopen($mode) {
    
    // create a file in the script directory
    $h = fopen($scriptFile, "w");
-   fwrite($h, "in script dir");
+   fwrite($h, (binary) "in script dir");
    fclose($h);
    
    //should read the file in script dir
@@ -126,7 +123,6 @@ function test_fopen($mode) {
 ?>
 ===DONE===
 --EXPECTF--
-*** Testing fopen() : variation ***
 
 --- testing include path ---
 
@@ -134,39 +130,21 @@ function test_fopen($mode) {
 in dir2
 in dir1
 in dir1
-
-Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
-
-Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
-
+in working dir
 in script dir
 
 ** testing with mode=r+ **
 in dir2
 in dir1
 in dir1
-
-Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
-
-Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
-
+in working dir
 in script dir
 
 ** testing with mode=rt **
 in dir2
 in dir1
 in dir1
-
-Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
-
-Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
-
+in working dir
 in script dir
 ===DONE===
 
index f144b225631a12af487b99c47321c7e6b2e29cb4..4b0a7270db5a34777b720ae63da394373ddc5b07 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Test fopen() function : variation: use include path and stream context create a file, relative path
---XFAIL--
-Pending completion of Unicode streams
 --CREDITS--
 Dave Kelsey <d_kelsey@uk.ibm.com>
 --FILE--
@@ -14,14 +12,14 @@ Dave Kelsey <d_kelsey@uk.ibm.com>
 
 require_once('fopen_include_path.inc');
 
-echo "*** Testing fopen() : variation ***\n";
-$thisTestDir = "fopenVariation9.dir";
+$thisTestDir =  basename(__FILE__, ".php") . ".dir";
 mkdir($thisTestDir);
 chdir($thisTestDir);
 
 $newpath = relative_include_path();
 set_include_path($newpath);
 runtest();
+
 $newpath = generate_next_rel_path();
 set_include_path($newpath);
 runtest();
@@ -32,9 +30,9 @@ chdir("..");
 rmdir($thisTestDir);
 
 function runtest() {
-       $tmpfile = 'fopen_variation7.tmp';
+       $tmpfile =  basename(__FILE__, ".php") . ".tmp";
        $h = fopen($tmpfile, "w", true);
-       fwrite($h, "This is the test file");
+       fwrite($h, (binary) "This is the test file");
        fclose($h);
        
        
@@ -48,7 +46,7 @@ function runtest() {
           unlink($tmpfile);
        }
        
-       $h = fopen('dir1/'.$tmpfile, "r");
+       $h = @fopen('dir1/'.$tmpfile, "r");
        if ($h === false) {
           echo "Not created in dir1\n";
        }
@@ -61,9 +59,8 @@ function runtest() {
 ?>
 ===DONE===
 --EXPECT--
-*** Testing fopen() : variation ***
-Not created in working dir
-created in dir1
-Not created in working dir
-created in dir1
+created in working dir
+Not created in dir1
+created in working dir
+Not created in dir1
 ===DONE===