summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2015-05-10 23:33:44 -0700
committerJulien Pauli <jpauli@php.net>2015-05-13 11:31:20 +0200
commitb91f75914edbe06d68895f4f96d5da6f302ec936 (patch)
tree59b715cb285fd9b575f7231022aeeab756e927aa
parent05b6f2598319108cc2b08ebb4e77a1a247bb8427 (diff)
downloadphp-git-b91f75914edbe06d68895f4f96d5da6f302ec936.tar.gz
Update tests
Conflicts: ext/standard/tests/dir/opendir_variation1-win32.phpt
-rw-r--r--ext/standard/tests/dir/dir_variation1.phpt22
-rw-r--r--ext/standard/tests/dir/opendir_variation1-win32.phpt248
-rw-r--r--ext/standard/tests/dir/opendir_variation1.phpt12
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_variation2.phpt2
-rw-r--r--ext/standard/tests/file/tempnam_variation3-win32.phpt18
-rw-r--r--ext/standard/tests/file/tempnam_variation3.phpt22
-rw-r--r--ext/standard/tests/general_functions/include_path.phpt4
7 files changed, 289 insertions, 39 deletions
diff --git a/ext/standard/tests/dir/dir_variation1.phpt b/ext/standard/tests/dir/dir_variation1.phpt
index abb4719504..fff04ba8f9 100644
--- a/ext/standard/tests/dir/dir_variation1.phpt
+++ b/ext/standard/tests/dir/dir_variation1.phpt
@@ -8,7 +8,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
-/*
+/*
* Prototype : object dir(string $directory[, resource $context])
* Description: Directory class with properties, handle and class and methods read, rewind and close
* Source code: ext/standard/dir.c
@@ -34,7 +34,7 @@ class A
}
// get a resource variable
-$fp = fopen(__FILE__, "r"); // get a file handle
+$fp = fopen(__FILE__, "r"); // get a file handle
$dfp = opendir( dirname(__FILE__) ); // get a dir handle
// unexpected values to be passed to $directory argument
@@ -92,27 +92,27 @@ echo "Done";
-- Iteration 1 --
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 2 --
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 3 --
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 4 --
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 5 --
-Warning: dir() expects parameter 1 to be string, array given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 6 --
@@ -151,16 +151,16 @@ bool(false)
-- Iteration 16 --
-Warning: dir() expects parameter 1 to be string, resource given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
NULL
-- Iteration 17 --
-Warning: dir() expects parameter 1 to be string, resource given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
NULL
-- Iteration 18 --
-Warning: dir() expects parameter 1 to be string, object given in %s on line %d
+Warning: dir() expects parameter 1 to be a valid path, object given in %s on line %d
NULL
-Done \ No newline at end of file
+Done
diff --git a/ext/standard/tests/dir/opendir_variation1-win32.phpt b/ext/standard/tests/dir/opendir_variation1-win32.phpt
new file mode 100644
index 0000000000..9bf3c4a883
--- /dev/null
+++ b/ext/standard/tests/dir/opendir_variation1-win32.phpt
@@ -0,0 +1,248 @@
+--TEST--
+Test opendir() function : usage variations - different data types as $path arg
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die("skip Valid only on Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : mixed opendir(string $path[, resource $context])
+ * Description: Open a directory and return a dir_handle
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Pass different data types as $path argument to opendir() to test behaviour
+ * Where possible, an existing directory has been entered as a string value
+ */
+
+echo "*** Testing opendir() : usage variations ***\n";
+
+// create directory to be passed as string value where possible
+$path = dirname(__FILE__) . "/opendir_variation1";
+mkdir($path);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// get a class
+class classA {
+
+ var $path;
+ function __construct($path) {
+ $this->path = $path;
+ }
+ public function __toString() {
+ return $this->path;
+ }
+}
+
+// heredoc string
+$heredoc = <<<EOT
+$path
+EOT;
+
+// get a resource variable
+$fp = fopen(__FILE__, "r");
+
+// unexpected values to be passed to $path argument
+$inputs = array(
+
+ // int data
+/*1*/ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+/*5*/ 10.5,
+ -10.5,
+ 12.3456789000e10,
+ 12.3456789000E-10,
+ .5,
+
+ // null data
+/*10*/ NULL,
+ null,
+
+ // boolean data
+/*12*/ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+/*16*/ "",
+ '',
+ array(),
+
+ // string data
+/*19*/ "$path",
+ 'string',
+ $heredoc,
+
+ // object data
+/*22*/ new classA($path),
+
+ // undefined data
+/*23*/ @$undefined_var,
+
+ // unset data
+/*24*/ @$unset_var,
+
+ // resource variable
+/*25*/ $fp
+);
+
+// loop through each element of $inputs to check the behavior of opendir()
+$iterator = 1;
+foreach($inputs as $input) {
+ echo "\n-- Iteration $iterator --\n";
+ var_dump( $dh = opendir($input) );
+ if ($dh) {
+ closedir($dh);
+ }
+ $iterator++;
+};
+
+fclose($fp);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . "/opendir_variation1";
+rmdir($path);
+?>
+--EXPECTF--
+*** Testing opendir() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: opendir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(0): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(1): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: opendir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(12345): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: opendir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(-2345): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: opendir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(10.5): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: opendir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(-10.5): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: opendir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(123456789000): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: opendir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(1.23456789E-9): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: opendir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(0.5): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+bool(false)
+
+-- Iteration 11 --
+bool(false)
+
+-- Iteration 12 --
+
+Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(1): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+bool(false)
+
+-- Iteration 14 --
+
+Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(1): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+bool(false)
+
+-- Iteration 16 --
+bool(false)
+
+-- Iteration 17 --
+bool(false)
+
+-- Iteration 18 --
+
+Warning: opendir() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+
+-- Iteration 19 --
+resource(%d) of type (stream)
+
+-- Iteration 20 --
+
+Warning: opendir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d
+
+Warning: opendir(string): failed to open dir: %s in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+resource(%d) of type (stream)
+
+-- Iteration 22 --
+resource(%d) of type (stream)
+
+-- Iteration 23 --
+bool(false)
+
+-- Iteration 24 --
+bool(false)
+
+-- Iteration 25 --
+
+Warning: opendir() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+===DONE===
diff --git a/ext/standard/tests/dir/opendir_variation1.phpt b/ext/standard/tests/dir/opendir_variation1.phpt
index 8d195e1e62..cb4d543f72 100644
--- a/ext/standard/tests/dir/opendir_variation1.phpt
+++ b/ext/standard/tests/dir/opendir_variation1.phpt
@@ -9,7 +9,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
--FILE--
<?php
/* Prototype : mixed opendir(string $path[, resource $context])
- * Description: Open a directory and return a dir_handle
+ * Description: Open a directory and return a dir_handle
* Source code: ext/standard/dir.c
*/
@@ -30,7 +30,7 @@ unset ($unset_var);
// get a class
class classA {
-
+
var $path;
function __construct($path) {
$this->path = $path;
@@ -73,7 +73,7 @@ $inputs = array(
false,
TRUE,
FALSE,
-
+
// empty data
/*16*/ "",
'',
@@ -83,7 +83,7 @@ $inputs = array(
/*19*/ "$path",
'string',
$heredoc,
-
+
// object data
/*22*/ new classA($path),
@@ -194,7 +194,7 @@ bool(false)
-- Iteration 18 --
-Warning: opendir() expects parameter 1 to be string, array given in %s on line %d
+Warning: opendir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 19 --
@@ -219,6 +219,6 @@ bool(false)
-- Iteration 25 --
-Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d
+Warning: opendir() expects parameter 1 to be a valid path, resource given in %s on line %d
NULL
===DONE===
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
index 14dd361e07..24dfc96ac9 100644
--- a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
+++ b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
@@ -68,7 +68,7 @@ bool(false)
Warning: mkdir() expects parameter 1 to be a valid path, string given in %s on line %d
bool(false)
-Warning: rmdir(%s): No such file or directory in %s on line %d
+Warning: rmdir() expects parameter 1 to be a valid path, string given in %s on line %d
bool(false)
*** Testing mkdir() with miscelleneous input ***
diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt
index fb457cb6ab..cc8194afa3 100644
--- a/ext/standard/tests/file/tempnam_variation3-win32.phpt
+++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt
@@ -22,9 +22,9 @@ if (!mkdir($file_path)) {
$file_path = realpath($file_path);
-/* An array of prefixes */
+/* An array of prefixes */
$names_arr = array(
- /* Valid args (casting)*/
+ /* Valid args (casting)*/
-1,
TRUE,
FALSE,
@@ -32,17 +32,17 @@ $names_arr = array(
"",
" ",
"\0",
- /* Invalid args */
+ /* Invalid args */
array(),
- /* Valid args*/
+ /* Valid args*/
/* prefix with path separator of a non existing directory*/
- "/no/such/file/dir",
+ "/no/such/file/dir",
"php/php"
);
$res_arr = array(
- /* Invalid args */
+ /* Invalid args */
true,
true,
true,
@@ -53,7 +53,7 @@ $res_arr = array(
false,
/* prefix with path separator of a non existing directory*/
- true,
+ true,
true
);
@@ -72,7 +72,7 @@ for( $i=0; $i<count($names_arr); $i++ ) {
} else {
echo "Failed, not created in the correct directory " . realpath($file_dir) . ' vs ' . $file_path ."\n";
}
-
+
if (!is_writable($file_name)) {
printf("%o\n", fileperms($file_name) );
@@ -105,7 +105,7 @@ Failed, not created in the correct directory %s vs %s
OK
-- Iteration 7 --
-Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
+Warning: tempnam() expects parameter 2 to be a valid path, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
OK
-- Iteration 8 --
OK
diff --git a/ext/standard/tests/file/tempnam_variation3.phpt b/ext/standard/tests/file/tempnam_variation3.phpt
index 69ab16c896..11b87809fc 100644
--- a/ext/standard/tests/file/tempnam_variation3.phpt
+++ b/ext/standard/tests/file/tempnam_variation3.phpt
@@ -17,9 +17,9 @@ echo "*** Testing tempnam() with obscure prefixes ***\n";
$file_path = dirname(__FILE__)."/tempnamVar3";
mkdir($file_path);
-/* An array of prefixes */
+/* An array of prefixes */
$names_arr = array(
- /* Invalid args */
+ /* Invalid args */
-1,
TRUE,
FALSE,
@@ -30,7 +30,7 @@ $names_arr = array(
array(),
/* prefix with path separator of a non existing directory*/
- "/no/such/file/dir",
+ "/no/such/file/dir",
"php/php"
);
@@ -48,10 +48,10 @@ for( $i=0; $i<count($names_arr); $i++ ) {
echo "File permissions are => ";
printf("%o", fileperms($file_name) );
echo "\n";
-
+
echo "File created in => ";
$file_dir = dirname($file_name);
-
+
if ($file_dir == sys_get_temp_dir()) {
echo "temp dir\n";
}
@@ -61,7 +61,7 @@ for( $i=0; $i<count($names_arr); $i++ ) {
else {
echo "unknown location\n";
}
-
+
}
else {
echo "-- File is not created --\n";
@@ -100,12 +100,14 @@ File name is => %s/%s
File permissions are => 100600
File created in => directory specified
-- Iteration 6 --
-File name is => %s/%s
-File permissions are => 100600
-File created in => directory specified
+
+Warning: tempnam() expects parameter 2 to be a valid path, string given in %s on line %d
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
-- Iteration 7 --
-Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
+Warning: tempnam() expects parameter 2 to be a valid path, array given in %s on line %d
-- File is not created --
Warning: unlink(): %s in %s on line %d
diff --git a/ext/standard/tests/general_functions/include_path.phpt b/ext/standard/tests/general_functions/include_path.phpt
index 039230784d..8b6626fbc8 100644
--- a/ext/standard/tests/general_functions/include_path.phpt
+++ b/ext/standard/tests/general_functions/include_path.phpt
@@ -41,7 +41,7 @@ var_dump(get_include_path());
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
string(1) "."
Warning: get_include_path() expects exactly 0 parameters, 1 given in %s on line %d
@@ -67,7 +67,7 @@ string(1) "."
NULL
string(1) "."
-Warning: set_include_path() expects parameter 1 to be string, array given in %s on line %d
+Warning: set_include_path() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
string(1) "."
NULL