Annotation of embedaddon/php/ext/standard/tests/file/fopen_variation14.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test fopen() function : variation: file uri, no use include path
! 3: --CREDITS--
! 4: Dave Kelsey <d_kelsey@uk.ibm.com>
! 5: --SKIPIF--
! 6: <?php
! 7: if(substr(PHP_OS, 0, 3) == "WIN")
! 8: die("skip not for Windows");
! 9: ?>
! 10: --FILE--
! 11: <?php
! 12: /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
! 13: * Description: Open a file or a URL and return a file pointer
! 14: * Source code: ext/standard/file.c
! 15: * Alias to functions:
! 16: */
! 17:
! 18: echo "*** Testing fopen() : variation ***\n";
! 19:
! 20: // fopen with interesting windows paths.
! 21: $testDir = 'fopen14.tmpDir';
! 22: $absTestDir = getcwd().'/'.$testDir;
! 23: $file = "fopen_variation14.tmp";
! 24: $absFile = $absTestDir.'/'.$file;
! 25:
! 26: mkdir($testDir);
! 27:
! 28: $files = array("file://$testDir/$file",
! 29: "file://./$testDir/$file",
! 30: "file://$absTestDir/$file"
! 31: );
! 32:
! 33: runtest($files);
! 34:
! 35: chdir($testDir);
! 36: $files = array("file://../$testDir/$file",
! 37: "file://$absTestDir/$file",
! 38: );
! 39: runtest($files);
! 40: chdir("..");
! 41: rmdir($testDir);
! 42:
! 43: function runtest($fileURIs) {
! 44: global $absFile;
! 45: $iteration = 0;
! 46: foreach($fileURIs as $fileURI) {
! 47: echo "--- READ: $fileURI ---\n";
! 48:
! 49: $readData = "read:$iteration";
! 50: $writeData = "write:$iteration";
! 51:
! 52: // create the file and test read
! 53: $h = fopen($absFile, 'w');
! 54: fwrite($h, $readData);
! 55: fclose($h);
! 56:
! 57: $h = fopen($fileURI, 'r');
! 58: if ($h !== false) {
! 59: if (fread($h, 4096) != $readData) {
! 60: echo "contents not correct\n";
! 61: }
! 62: else {
! 63: echo "test passed\n";
! 64: }
! 65: fclose($h);
! 66: }
! 67: unlink($absFile);
! 68:
! 69: echo "--- WRITE: $fileURI ---\n";
! 70: // create the file to test write
! 71: $h = fopen($fileURI, 'w');
! 72: if ($h !== false) {
! 73: fwrite($h, $writeData);
! 74: fclose($h);
! 75:
! 76: $h = fopen($absFile, 'r');
! 77: if ($h !== false) {
! 78: if (fread($h, 4096) != $writeData) {
! 79: echo "contents not correct\n";
! 80: }
! 81: else {
! 82: echo "test passed\n";
! 83: }
! 84: fclose($h);
! 85: }
! 86: unlink($absFile);
! 87: }
! 88: }
! 89: }
! 90:
! 91:
! 92: ?>
! 93: ===DONE===
! 94: --EXPECTF--
! 95: *** Testing fopen() : variation ***
! 96: --- READ: file://fopen14.tmpDir/fopen_variation14.tmp ---
! 97:
! 98: Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
! 99:
! 100: Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
! 101: --- WRITE: file://fopen14.tmpDir/fopen_variation14.tmp ---
! 102:
! 103: Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
! 104:
! 105: Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
! 106: --- READ: file://./fopen14.tmpDir/fopen_variation14.tmp ---
! 107:
! 108: Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
! 109:
! 110: Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
! 111: --- WRITE: file://./fopen14.tmpDir/fopen_variation14.tmp ---
! 112:
! 113: Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
! 114:
! 115: Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
! 116: --- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
! 117: test passed
! 118: --- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
! 119: test passed
! 120: --- READ: file://../fopen14.tmpDir/fopen_variation14.tmp ---
! 121:
! 122: Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
! 123:
! 124: Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
! 125: --- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp ---
! 126:
! 127: Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
! 128:
! 129: Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
! 130: --- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
! 131: test passed
! 132: --- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
! 133: test passed
! 134: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>