stevseea                Wed Mar 19 17:26:36 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/file    realpath_basic2.phpt 
                                        fseek_dir_basic.phpt 
                                        realpath_basic3.phpt 
                                        fopen_variation1.phpt 
                                        parse_ini_file_error.phpt 
                                        fread_socket_variation1.phpt 
                                        glob_variation2.phpt 
  Log:
  Adding filesystem tests
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/realpath_basic2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/realpath_basic2.phpt
diff -u /dev/null php-src/ext/standard/tests/file/realpath_basic2.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/realpath_basic2.phpt        Wed Mar 19 
17:26:36 2008
@@ -0,0 +1,13 @@
+--TEST--
+realpath() with relative directory
+--FILE--
+<?php
+
+var_dump(realpath('.') == getcwd());
+chdir('..');
+var_dump(realpath('.') == getcwd());
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fseek_dir_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/fseek_dir_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/file/fseek_dir_basic.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/fseek_dir_basic.phpt        Wed Mar 19 
17:26:36 2008
@@ -0,0 +1,93 @@
+--TEST--
+Testing fseek() on a directory stream
+--FILE--
+<?php
+
+// include the file.inc for Function: function create_files()
+require(dirname(__FILE__) . '/file.inc');
+
+$path = dirname(__FILE__) . '/fseek_dir_basic';
+mkdir($path);
+create_files($path, 3);
+
+echo "call readdir():\n";
+var_dump($dh = opendir($path));
+while( FALSE !== ($file = readdir($dh)) ) {
+       var_dump($file);
+}
+
+echo "\ncall fseek() on directory resource:\n";
+var_dump(fseek($dh, 20));
+
+echo "call readdir():\n";
+while( FALSE !== ($file = readdir($dh)) ) {
+       var_dump($file);
+}
+
+echo "\ncall fseek() with different arguments on directory resource:\n";
+var_dump(fseek($dh, 20, SEEK_END));
+
+echo "call readdir():\n";
+while( FALSE !== ($file = readdir($dh)) ) {
+       var_dump($file);
+}
+
+delete_files($path, 3);
+closedir($dh);
+var_dump(rmdir($path));
+
+?>
+--EXPECTF--
+call readdir():
+resource(%d) of type (stream)
+string(1) "."
+string(2) ".."
+string(9) "file1.tmp"
+string(9) "file2.tmp"
+string(9) "file3.tmp"
+
+call fseek() on directory resource:
+int(0)
+call readdir():
+string(1) "."
+string(2) ".."
+string(9) "file1.tmp"
+string(9) "file2.tmp"
+string(9) "file3.tmp"
+
+call fseek() with different arguments on directory resource:
+int(0)
+call readdir():
+string(1) "."
+string(2) ".."
+string(9) "file1.tmp"
+string(9) "file2.tmp"
+string(9) "file3.tmp"
+bool(true)
+--UEXPECTF--
+call readdir():
+resource(%d) of type (stream)
+unicode(1) "."
+unicode(2) ".."
+unicode(9) "file1.tmp"
+unicode(9) "file2.tmp"
+unicode(9) "file3.tmp"
+
+call fseek() on directory resource:
+int(0)
+call readdir():
+unicode(1) "."
+unicode(2) ".."
+unicode(9) "file1.tmp"
+unicode(9) "file2.tmp"
+unicode(9) "file3.tmp"
+
+call fseek() with different arguments on directory resource:
+int(0)
+call readdir():
+unicode(1) "."
+unicode(2) ".."
+unicode(9) "file1.tmp"
+unicode(9) "file2.tmp"
+unicode(9) "file3.tmp"
+bool(true)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/realpath_basic3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/realpath_basic3.phpt
diff -u /dev/null php-src/ext/standard/tests/file/realpath_basic3.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/realpath_basic3.phpt        Wed Mar 19 
17:26:36 2008
@@ -0,0 +1,112 @@
+--TEST--
+Test realpath() with relative paths
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+   Description: Returns canonicalized absolute pathname
+*/
+
+echo "\n*** Testing basic functions of realpath() with files ***\n";
+
+/* creating directories and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/realpath_basic/home/test/", 0777, true);
+
+$file_handle1 = 
fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w");
+$file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", 
"w");
+$file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+echo "\n*** Testing realpath() on filenames ***\n";
+$filenames = array (
+  /* filenames resulting in valid paths */
+  "./realpath_basic/home/realpath_basic.tmp",
+  "./realpath_basic/realpath_basic.tmp",
+  "./realpath_basic//home/test//../test/./realpath_basic.tmp",
+  "./realpath_basic/home//../././realpath_basic.tmp",
+
+  /* filenames with invalid path */
+  // checking for binary safe
+  "./realpath_basicx000/home/realpath_basic.tmp",
+
+  ".///realpath_basic/home//..//././test//realpath_basic.tmp",
+  "./realpath_basic/home/../home/../test/..realpath_basic.tmp"
+);
+
+chdir("$file_path/..");
+chdir($file_path);
+
+$counter = 1;
+/* loop through $files to read the filepath of $file in the above array */
+foreach($filenames as $file) {
+  echo "\n-- Iteration $counter --\n";
+  var_dump( realpath($file) );
+  $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/realpath_basic";
+unlink("$name_prefix/home/test/realpath_basic.tmp");
+unlink("$name_prefix/home/realpath_basic.tmp");
+unlink("$name_prefix/realpath_basic.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing basic functions of realpath() with files ***
+
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+string(%d) "%srealpath_basic%shome%srealpath_basic.tmp"
+
+-- Iteration 2 --
+string(%d) "%srealpath_basic%srealpath_basic.tmp"
+
+-- Iteration 3 --
+string(%d) "%srealpath_basic%shome%stest%srealpath_basic.tmp"
+
+-- Iteration 4 --
+string(%d) "%srealpath_basic%srealpath_basic.tmp"
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+Done
+--UEXPECTF--
+*** Testing basic functions of realpath() with files ***
+
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+unicode(%d) "%srealpath_basic%shome%srealpath_basic.tmp"
+
+-- Iteration 2 --
+unicode(%d) "%srealpath_basic%srealpath_basic.tmp"
+
+-- Iteration 3 --
+unicode(%d) "%srealpath_basic%shome%stest%srealpath_basic.tmp"
+
+-- Iteration 4 --
+unicode(%d) "%srealpath_basic%srealpath_basic.tmp"
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fopen_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/fopen_variation1.phpt
diff -u /dev/null php-src/ext/standard/tests/file/fopen_variation1.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/fopen_variation1.phpt       Wed Mar 19 
17:26:36 2008
@@ -0,0 +1,14 @@
+--TEST--
+fopen() with relative path on a file in the script directory
+--FILE--
+<?php
+
+$file = basename(__FILE__);
+
+$fd = fopen($file, "r", true);
+var_dump($fd);
+fclose($fd);
+
+?>
+--EXPECTF--
+resource(%d) of type (stream)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/parse_ini_file_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/parse_ini_file_error.phpt
diff -u /dev/null php-src/ext/standard/tests/file/parse_ini_file_error.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/parse_ini_file_error.phpt   Wed Mar 19 
17:26:36 2008
@@ -0,0 +1,53 @@
+--TEST--
+Test parse_ini_file() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : proto array parse_ini_file(string filename [, bool 
process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+/*
+ * add a comment here to say what the test is supposed to do
+ */
+
+echo "*** Testing parse_ini_file() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing parse_ini_file() function with Zero arguments --\n";
+var_dump( parse_ini_file() );
+
+//Test parse_ini_file with one more than the expected number of arguments
+echo "\n-- Testing parse_ini_file() function with more than expected no. of 
arguments --\n";
+$filename = 'string_val';
+$process_sections = true;
+$extra_arg = 10;
+var_dump( parse_ini_file($filename, $process_sections, $extra_arg) );
+
+echo "\n-- Testing parse_ini_file() function with a non-existent file --\n";
+$filename = __FILE__ . 'invalidfilename';
+var_dump( parse_ini_file($filename, $process_sections) ); 
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : error conditions ***
+
+-- Testing parse_ini_file() function with Zero arguments --
+
+Warning: parse_ini_file() expects at least 1 parameter, 0 given in %s on line 
%d
+bool(false)
+
+-- Testing parse_ini_file() function with more than expected no. of arguments 
--
+
+Warning: parse_ini_file(%s): failed to open stream: No such file or directory 
in %s on line %d
+array(0) {
+}
+
+-- Testing parse_ini_file() function with a non-existent file --
+
+Warning: parse_ini_file(%s): failed to open stream: No such file or directory 
in %s on line %d
+array(0) {
+}
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fread_socket_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/fread_socket_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/file/fread_socket_variation1.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/fread_socket_variation1.phpt        Wed Mar 
19 17:26:36 2008
@@ -0,0 +1,16 @@
+--TEST--
+Testing fread() on a TCP server socket
+--FILE--
+<?php
+
+$tcp_socket = stream_socket_server('tcp://127.0.0.1:31337');
+
+socket_set_timeout($tcp_socket, 1);
+
+var_dump(fread($tcp_socket, 1));
+
+fclose($tcp_socket);
+
+?>
+--EXPECT--
+bool(false)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/glob_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/glob_variation2.phpt
diff -u /dev/null php-src/ext/standard/tests/file/glob_variation2.phpt:1.2
--- /dev/null   Wed Mar 19 17:26:36 2008
+++ php-src/ext/standard/tests/file/glob_variation2.phpt        Wed Mar 19 
17:26:36 2008
@@ -0,0 +1,76 @@
+--TEST--
+Test glob() function with relative path
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+   Description: Find pathnames matching a pattern
+*/
+
+$file_path = dirname(__FILE__);
+
+// temp dirname used here
+$dir_name = 'glob_test';
+
+// create temp directory
+mkdir("$file_path/$dir_name");
+
+// create temp file
+$fp = fopen("$file_path/$dir_name/file.text", "w");
+fclose($fp);
+
+echo "Testing glob() with relative paths:\n";
+
+chdir("$file_path/$dir_name");
+var_dump( glob("./*") );
+var_dump( glob("../$dir_name/*"));
+
+chdir("$file_path");
+var_dump( glob("$dir_name/*"));
+var_dump( glob("$dir_name"));
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/glob_test/file.text");
+rmdir("$file_path/glob_test/");
+?>
+--EXPECT--
+Testing glob() with relative paths:
+array(1) {
+  [0]=>
+  string(11) "./file.text"
+}
+array(1) {
+  [0]=>
+  string(22) "../glob_test/file.text"
+}
+array(1) {
+  [0]=>
+  string(19) "glob_test/file.text"
+}
+array(1) {
+  [0]=>
+  string(9) "glob_test"
+}
+Done
+--UEXPECT--
+Testing glob() with relative paths:
+array(1) {
+  [0]=>
+  unicode(11) "./file.text"
+}
+array(1) {
+  [0]=>
+  unicode(22) "../glob_test/file.text"
+}
+array(1) {
+  [0]=>
+  unicode(19) "glob_test/file.text"
+}
+array(1) {
+  [0]=>
+  unicode(9) "glob_test"
+}
+Done
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to