diff options
Diffstat (limited to 'ext/standard/tests')
77 files changed, 1414 insertions, 1344 deletions
diff --git a/ext/standard/tests/array/array_column_basic.phpt b/ext/standard/tests/array/array_column_basic.phpt new file mode 100644 index 0000000000..418f373872 --- /dev/null +++ b/ext/standard/tests/array/array_column_basic.phpt @@ -0,0 +1,327 @@ +--TEST-- +Test array_column() function: basic functionality +--FILE-- +<?php +/* Prototype: + * array array_column(array $input, mixed $column_key[, mixed $index_key]); + * Description: + * Returns an array containing all the values from + * the specified "column" in a two-dimensional array. + */ + +echo "*** Testing array_column() : basic functionality ***\n"; +/* Array representing a possible record set returned from a database */ +$records = array( + array( + 'id' => 1, + 'first_name' => 'John', + 'last_name' => 'Doe' + ), + array( + 'id' => 2, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), + array( + 'id' => 3, + 'first_name' => 'Jane', + 'last_name' => 'Jones' + ) +); + +echo "-- first_name column from recordset --\n"; +var_dump(array_column($records, 'first_name')); + +echo "-- id column from recordset --\n"; +var_dump(array_column($records, 'id')); + +echo "-- last_name column from recordset, keyed by value from id column --\n"; +var_dump(array_column($records, 'last_name', 'id')); + +echo "-- last_name column from recordset, keyed by value from first_name column --\n"; +var_dump(array_column($records, 'last_name', 'first_name')); + +echo "\n*** Testing multiple data types ***\n"; +$fh = fopen(__FILE__, 'r', true); +$values = array( + array( + 'id' => 1, + 'value' => new stdClass + ), + array( + 'id' => 2, + 'value' => 34.2345 + ), + array( + 'id' => 3, + 'value' => true + ), + array( + 'id' => 4, + 'value' => false + ), + array( + 'id' => 5, + 'value' => null + ), + array( + 'id' => 6, + 'value' => 1234 + ), + array( + 'id' => 7, + 'value' => 'Foo' + ), + array( + 'id' => 8, + 'value' => $fh + ) +); +var_dump(array_column($values, 'value')); +var_dump(array_column($values, 'value', 'id')); + +echo "\n*** Testing numeric column keys ***\n"; +$numericCols = array( + array('aaa', '111'), + array('bbb', '222'), + array('ccc', '333', -1 => 'ddd') +); +var_dump(array_column($numericCols, 1)); +var_dump(array_column($numericCols, 1, 0)); +var_dump(array_column($numericCols, 1, 0.123)); +var_dump(array_column($numericCols, 1, -1)); + +echo "\n*** Testing failure to find specified column ***\n"; +var_dump(array_column($numericCols, 2)); +var_dump(array_column($numericCols, 'foo')); +var_dump(array_column($numericCols, 0, 'foo')); +var_dump(array_column($numericCols, 3.14)); + +echo "\n*** Testing single dimensional array ***\n"; +$singleDimension = array('foo', 'bar', 'baz'); +var_dump(array_column($singleDimension, 1)); + +echo "\n*** Testing columns not present in all rows ***\n"; +$mismatchedColumns = array( + array('a' => 'foo', 'b' => 'bar', 'e' => 'bbb'), + array('a' => 'baz', 'c' => 'qux', 'd' => 'aaa'), + array('a' => 'eee', 'b' => 'fff', 'e' => 'ggg'), +); +var_dump(array_column($mismatchedColumns, 'c')); +var_dump(array_column($mismatchedColumns, 'c', 'a')); +var_dump(array_column($mismatchedColumns, 'a', 'd')); +var_dump(array_column($mismatchedColumns, 'a', 'e')); +var_dump(array_column($mismatchedColumns, 'b')); +var_dump(array_column($mismatchedColumns, 'b', 'a')); + +echo "\n*** Testing use of object converted to string ***\n"; +class Foo +{ + public function __toString() + { + return 'last_name'; + } +} +class Bar +{ + public function __toString() + { + return 'first_name'; + } +} +$f = new Foo(); +$b = new Bar(); +var_dump(array_column($records, $f)); +var_dump(array_column($records, $f, $b)); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_column() : basic functionality *** +-- first_name column from recordset -- +array(3) { + [0]=> + string(4) "John" + [1]=> + string(5) "Sally" + [2]=> + string(4) "Jane" +} +-- id column from recordset -- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +-- last_name column from recordset, keyed by value from id column -- +array(3) { + [1]=> + string(3) "Doe" + [2]=> + string(5) "Smith" + [3]=> + string(5) "Jones" +} +-- last_name column from recordset, keyed by value from first_name column -- +array(3) { + ["John"]=> + string(3) "Doe" + ["Sally"]=> + string(5) "Smith" + ["Jane"]=> + string(5) "Jones" +} + +*** Testing multiple data types *** +array(8) { + [0]=> + object(stdClass)#%d (0) { + } + [1]=> + float(34.2345) + [2]=> + bool(true) + [3]=> + bool(false) + [4]=> + NULL + [5]=> + int(1234) + [6]=> + string(3) "Foo" + [7]=> + resource(%d) of type (stream) +} +array(8) { + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + float(34.2345) + [3]=> + bool(true) + [4]=> + bool(false) + [5]=> + NULL + [6]=> + int(1234) + [7]=> + string(3) "Foo" + [8]=> + resource(%d) of type (stream) +} + +*** Testing numeric column keys *** +array(3) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + [2]=> + string(3) "333" +} +array(3) { + ["aaa"]=> + string(3) "111" + ["bbb"]=> + string(3) "222" + ["ccc"]=> + string(3) "333" +} +array(3) { + ["aaa"]=> + string(3) "111" + ["bbb"]=> + string(3) "222" + ["ccc"]=> + string(3) "333" +} +array(3) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + ["ddd"]=> + string(3) "333" +} + +*** Testing failure to find specified column *** +array(0) { +} +array(0) { +} +array(3) { + [0]=> + string(3) "aaa" + [1]=> + string(3) "bbb" + [2]=> + string(3) "ccc" +} +array(0) { +} + +*** Testing single dimensional array *** +array(0) { +} + +*** Testing columns not present in all rows *** +array(1) { + [0]=> + string(3) "qux" +} +array(1) { + ["baz"]=> + string(3) "qux" +} +array(3) { + [0]=> + string(3) "foo" + ["aaa"]=> + string(3) "baz" + [1]=> + string(3) "eee" +} +array(3) { + ["bbb"]=> + string(3) "foo" + [0]=> + string(3) "baz" + ["ggg"]=> + string(3) "eee" +} +array(2) { + [0]=> + string(3) "bar" + [1]=> + string(3) "fff" +} +array(2) { + ["foo"]=> + string(3) "bar" + ["eee"]=> + string(3) "fff" +} + +*** Testing use of object converted to string *** +array(3) { + [0]=> + string(3) "Doe" + [1]=> + string(5) "Smith" + [2]=> + string(5) "Jones" +} +array(3) { + ["John"]=> + string(3) "Doe" + ["Sally"]=> + string(5) "Smith" + ["Jane"]=> + string(5) "Jones" +} +Done diff --git a/ext/standard/tests/array/array_column_error.phpt b/ext/standard/tests/array/array_column_error.phpt new file mode 100644 index 0000000000..bdcbec0062 --- /dev/null +++ b/ext/standard/tests/array/array_column_error.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test array_column() function: error conditions +--FILE-- +<?php +/* Prototype: + * array array_column(array $input, mixed $column_key[, mixed $index_key]); + * Description: + * Returns an array containing all the values from + * the specified "column" in a two-dimensional array. + */ + +echo "*** Testing array_column() : error conditions ***\n"; + +echo "\n-- Testing array_column() function with Zero arguments --\n"; +var_dump(array_column()); + +echo "\n-- Testing array_column() function with One argument --\n"; +var_dump(array_column(array())); + +echo "\n-- Testing array_column() function with string as first parameter --\n"; +var_dump(array_column('foo', 0)); + +echo "\n-- Testing array_column() function with int as first parameter --\n"; +var_dump(array_column(1, 'foo')); + +echo "\n-- Testing array_column() column key parameter should be a string or an integer (testing bool) --\n"; +var_dump(array_column(array(), true)); + +echo "\n-- Testing array_column() column key parameter should be a string or integer (testing array) --\n"; +var_dump(array_column(array(), array())); + +echo "\n-- Testing array_column() index key parameter should be a string or an integer (testing bool) --\n"; +var_dump(array_column(array(), 'foo', true)); + +echo "\n-- Testing array_column() index key parameter should be a string or integer (testing array) --\n"; +var_dump(array_column(array(), 'foo', array())); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing array_column() : error conditions *** + +-- Testing array_column() function with Zero arguments -- + +Warning: array_column() expects at least 2 parameters, 0 given in %s on line %d +NULL + +-- Testing array_column() function with One argument -- + +Warning: array_column() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing array_column() function with string as first parameter -- + +Warning: array_column() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Testing array_column() function with int as first parameter -- + +Warning: array_column() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Testing array_column() column key parameter should be a string or an integer (testing bool) -- + +Warning: array_column(): The column key should be either a string or an integer in %s on line %d +bool(false) + +-- Testing array_column() column key parameter should be a string or integer (testing array) -- + +Warning: array_column(): The column key should be either a string or an integer in %s on line %d +bool(false) + +-- Testing array_column() index key parameter should be a string or an integer (testing bool) -- + +Warning: array_column(): The index key should be either a string or an integer in %s on line %d +bool(false) + +-- Testing array_column() index key parameter should be a string or integer (testing array) -- + +Warning: array_column(): The index key should be either a string or an integer in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_column_object_cast.phpt b/ext/standard/tests/array/array_column_object_cast.phpt new file mode 100644 index 0000000000..762aaa81f4 --- /dev/null +++ b/ext/standard/tests/array/array_column_object_cast.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test array_column() function: basic functionality +--FILE-- +<?php +class ColumnKeyClass { + function __toString() { return 'first_name'; } +} + +class IndexKeyClass { + function __toString() { return 'id'; } +} + +class ValueClass { + function __toString() { return '2135'; } +} + + +$column_key = new ColumnKeyClass(); +$index_key = new IndexKeyClass(); +$value = new ValueClass(); + + +// Array representing a possible record set returned from a database +$records = array( + array( + 'id' => $value, + 'first_name' => 'John', + 'last_name' => 'XXX' + ), + array( + 'id' => 3245, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), +); +$firstNames = array_column($records, $column_key, $index_key); +print_r($firstNames); +var_dump($column_key); +var_dump($index_key); +var_dump($value); +--EXPECTF-- +Array +( + [2135] => John + [3245] => Sally +) +object(ColumnKeyClass)#%d (0) { +} +object(IndexKeyClass)#%d (0) { +} +object(ValueClass)#%d (0) { +} diff --git a/ext/standard/tests/array/array_column_variant.phpt b/ext/standard/tests/array/array_column_variant.phpt new file mode 100644 index 0000000000..0af0869497 --- /dev/null +++ b/ext/standard/tests/array/array_column_variant.phpt @@ -0,0 +1,85 @@ +--TEST-- +Test array_column() function: variant functionality +--FILE-- +<?php +/* Array from Bug Request #64493 test script */ +$rows = array( + 456 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'), + 457 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'), +); + +echo "-- pass null as second parameter to get back all columns indexed by third parameter --\n"; +var_dump(array_column($rows, null, 'id')); + +echo "-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns --\n"; +var_dump(array_column($rows, null, 'foo')); + +echo "-- pass null as second parameter and no third param to get back array_values(input) --\n"; +var_dump(array_column($rows, null)); + +echo "Done\n"; +--EXPECTF-- +-- pass null as second parameter to get back all columns indexed by third parameter -- +array(2) { + [3]=> + array(3) { + ["id"]=> + string(1) "3" + ["title"]=> + string(3) "Foo" + ["date"]=> + string(10) "2013-03-25" + } + [5]=> + array(3) { + ["id"]=> + string(1) "5" + ["title"]=> + string(3) "Bar" + ["date"]=> + string(10) "2012-05-20" + } +} +-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns -- +array(2) { + [0]=> + array(3) { + ["id"]=> + string(1) "3" + ["title"]=> + string(3) "Foo" + ["date"]=> + string(10) "2013-03-25" + } + [1]=> + array(3) { + ["id"]=> + string(1) "5" + ["title"]=> + string(3) "Bar" + ["date"]=> + string(10) "2012-05-20" + } +} +-- pass null as second parameter and no third param to get back array_values(input) -- +array(2) { + [0]=> + array(3) { + ["id"]=> + string(1) "3" + ["title"]=> + string(3) "Foo" + ["date"]=> + string(10) "2013-03-25" + } + [1]=> + array(3) { + ["id"]=> + string(1) "5" + ["title"]=> + string(3) "Bar" + ["date"]=> + string(10) "2012-05-20" + } +} +Done diff --git a/ext/standard/tests/array/compact.phpt b/ext/standard/tests/array/compact.phpt index 4b4bfbb732..02df44ebd8 100644 --- a/ext/standard/tests/array/compact.phpt +++ b/ext/standard/tests/array/compact.phpt @@ -1,8 +1,5 @@ --TEST-- compact() ---INI-- -unicode.script_encoding=UTF-8 -unicode.output_encoding=UTF-8 --FILE-- <?php diff --git a/ext/standard/tests/array/each.phpt b/ext/standard/tests/array/each.phpt Binary files differindex 19ee728fd2..974808c08c 100644 --- a/ext/standard/tests/array/each.phpt +++ b/ext/standard/tests/array/each.phpt diff --git a/ext/standard/tests/array/locale_sort.phpt b/ext/standard/tests/array/locale_sort.phpt index 1db96042e8..c2f66c01df 100644 --- a/ext/standard/tests/array/locale_sort.phpt +++ b/ext/standard/tests/array/locale_sort.phpt @@ -9,9 +9,6 @@ if (false == setlocale(LC_CTYPE, "fr_FR.ISO8859-1", "fr_FR")) { die("skip setlocale() failed\n"); } ?> ---INI-- -unicode.script_encoding=ISO8859-1 -unicode.output_encoding=ISO8859-1 --FILE-- <?php setlocale(LC_ALL, 'fr_FR.ISO8859-1', 'fr_FR'); diff --git a/ext/standard/tests/array/uasort_variation9.phpt b/ext/standard/tests/array/uasort_variation9.phpt index 486042e5e7..85578b0207 100644 --- a/ext/standard/tests/array/uasort_variation9.phpt +++ b/ext/standard/tests/array/uasort_variation9.phpt @@ -14,7 +14,7 @@ echo "*** Testing uasort() : 'cmp_function' with reference arguments ***\n"; // comparison function /* Prototype : int cmp(mixed &$value1, mixed &$value2) - * Parameters : $value1 and $value2 - values recieved by reference + * Parameters : $value1 and $value2 - values received by reference * Return value : 0 - if both values are same * 1 - if value1 is greater than value2 * -1 - if value1 is less than value2 diff --git a/ext/standard/tests/bug64370_var1.phpt b/ext/standard/tests/bug64370_var1.phpt index ff64d61616..aca46a594d 100644 --- a/ext/standard/tests/bug64370_var1.phpt +++ b/ext/standard/tests/bug64370_var1.phpt @@ -1,10 +1,5 @@ --TEST-- Test bug #64370 microtime(true) less than $_SERVER['REQUEST_TIME_FLOAT'] ---SKIPIF-- -<?php - if (PHP_MAJOR_VERSION < 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4)) { - die('skip PHP 5.4+ only'); - } --FILE-- <?php echo "\$_SERVER['REQUEST_TIME']: {$_SERVER['REQUEST_TIME']}\n"; diff --git a/ext/standard/tests/dir/dir_variation1-win32.phpt b/ext/standard/tests/dir/dir_variation1-win32.phpt deleted file mode 100644 index 1f7f4a2cf3..0000000000 --- a/ext/standard/tests/dir/dir_variation1-win32.phpt +++ /dev/null @@ -1,170 +0,0 @@ ---TEST-- -Test dir() function : usage variations - unexpected value for 'dir' argument ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---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 - */ - -/* - * Passing non string values to 'directory' argument of dir() and see - * that the function outputs proper warning messages wherever expected. - */ - -echo "*** Testing dir() : unexpected values for \$directory argument ***\n"; - -// get an unset variable -$unset_var = 10; -unset($unset_var); - -class A -{ - public $var; - public function init() { - $this->var = 10; - } -} - -// get a resource variable -$fp = fopen(__FILE__, "r"); // get a file handle -$dfp = opendir( dirname(__FILE__) ); // get a dir handle - -// unexpected values to be passed to $directory argument -$unexpected_values = array ( - - // array data -/*1*/ array(), - array(0), - array(1), - array(1, 2), - array('color' => 'red', 'item' => 'pen'), - - // null data -/*6*/ NULL, - null, - - // boolean data -/*8*/ true, - false, - TRUE, - FALSE, - - // empty data -/*12*/ "", - '', - - // undefined data -/*14*/ @$undefined_var, - - // unset data -/*15*/ @$unset_var, - - // resource variable(dir and file handle) -/*16*/ $fp, - $dfp, - - // object data -/*18*/ new A() -); - -// loop through various elements of $unexpected_values to check the behavior of dir() -$iterator = 1; -foreach( $unexpected_values as $unexpected_value ) { - echo "\n-- Iteration $iterator --\n"; - var_dump( dir($unexpected_value) ); - $iterator++; -} - -fclose($fp); -closedir($dfp); -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : unexpected values for $directory argument *** - --- Iteration 1 -- - -Warning: dir() expects parameter 1 to be string, 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 -NULL - --- Iteration 3 -- - -Warning: dir() expects parameter 1 to be string, 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 -NULL - --- Iteration 5 -- - -Warning: dir() expects parameter 1 to be string, array given in %s on line %d -NULL - --- Iteration 6 -- -bool(false) - --- Iteration 7 -- -bool(false) - --- Iteration 8 -- - -Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: dir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 9 -- -bool(false) - --- Iteration 10 -- - -Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: dir(1): failed to open dir: %s in %s on line %d -bool(false) - --- Iteration 11 -- -bool(false) - --- Iteration 12 -- -bool(false) - --- Iteration 13 -- -bool(false) - --- Iteration 14 -- -bool(false) - --- Iteration 15 -- -bool(false) - --- Iteration 16 -- - -Warning: dir() expects parameter 1 to be string, 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 -NULL - --- Iteration 18 -- - -Warning: dir() expects parameter 1 to be string, object given in %s on line %d -NULL -Done
\ No newline at end of file diff --git a/ext/standard/tests/dir/dir_variation5-win32.phpt b/ext/standard/tests/dir/dir_variation5-win32.phpt deleted file mode 100644 index e70b9d3533..0000000000 --- a/ext/standard/tests/dir/dir_variation5-win32.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test dir() function : usage variations - open a file instead of directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---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 - */ - -/* - * Passing a file as argument to dir() function instead of a directory - * and checking if proper warning message is generated. - */ - -echo "*** Testing dir() : open a file instead of a directory ***\n"; - -// open the file instead of directory -$d = dir(__FILE__); -var_dump( $d ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : open a file instead of a directory *** - -Warning: dir(%s): The directory name is invalid. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation6-win32.phpt b/ext/standard/tests/dir/dir_variation6-win32.phpt deleted file mode 100644 index e0e4749809..0000000000 --- a/ext/standard/tests/dir/dir_variation6-win32.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -Test dir() function : usage variations - non-existent directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---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 - */ - -/* - * Passing a non-existent directory as argument to dir() function - * and checking to see if proper warning message is output. - */ -echo "*** Testing dir() : open a non-existent directory ***\n"; - -// create the temporary directory -$file_path = dirname(__FILE__); -$dir_path = $file_path."/dir_variation6"; -@mkdir($dir_path); - -// open existent directory -$d = dir($dir_path); -$d->close(); //close the dir - -// remove directory and try to open the same(non-existent) directory again -rmdir($dir_path); -clearstatcache(); - -echo "-- opening previously removed directory --\n"; -var_dump( dir($dir_path) ); - -// point to a non-existent directory -$non_existent_dir = $file_path."/non_existent_dir"; -echo "-- opening non-existent directory --\n"; -$d = dir($non_existent_dir); -var_dump( $d ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : open a non-existent directory *** --- opening previously removed directory -- - -Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) --- opening non-existent directory -- - -Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: dir(%s): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation8-win32.phpt b/ext/standard/tests/dir/dir_variation8-win32.phpt deleted file mode 100644 index a56c98b880..0000000000 --- a/ext/standard/tests/dir/dir_variation8-win32.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Test dir() function : usage variations - checking with wildcard characters ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---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 - */ - -/* - * Create more than one temporary directory & subdirectory and check if dir() function can open - * those directories when wildcard characters are used to refer to them. - */ - -echo "*** Testing dir() : checking with wildcard characters ***\n"; - -// create the temporary directories -$file_path = dirname(__FILE__); -$dir_path = $file_path."/dir_variation81"; -$sub_dir_path = $dir_path."/sub_dir1"; - -@mkdir($dir_path1); -@mkdir($sub_dir_path); - -/* with different wildcard characters */ - -echo "-- wildcard = '*' --\n"; -var_dump( dir($file_path."/dir_var*") ); -var_dump( dir($file_path."/*") ); - -echo "-- wildcard = '?' --\n"; -var_dump( dir($dir_path."/sub_dir?") ); -var_dump( dir($dir_path."/sub?dir1") ); - -echo "Done"; -?> ---EXPECTF-- -*** Testing dir() : checking with wildcard characters *** --- wildcard = '*' -- - -Warning: dir(%s/dir_var*,%s/dir_var*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_var*): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%s/*,%s/*): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/*): failed to open dir: %s in %s on line %d -bool(false) --- wildcard = '?' -- - -Warning: dir(%s/dir_variation81/sub_dir?,%s/dir_variation81/sub_dir?): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_variation81/sub_dir?): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%s/dir_variation81/sub?dir1,%s/dir_variation81/sub?dir1): %r(No such file or directory|The system cannot find the path specified. \(code: 3\))%r in %s on line %d - -Warning: dir(%s/dir_variation81/sub?dir1): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/dir_variation9-win32.phpt b/ext/standard/tests/dir/dir_variation9-win32.phpt deleted file mode 100644 index 32b0bd946b..0000000000 --- a/ext/standard/tests/dir/dir_variation9-win32.phpt +++ /dev/null @@ -1,125 +0,0 @@ ---TEST-- -Test dir() function : usage variations - relative valid and invalid paths ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---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 - */ - -/* - * Checking the behavior of dir() function by passing directories which - * have valid and invalid relative path. - */ - -echo "*** Testing dir() : checking with valid and invalid paths ***\n"; - -/* create the temporary directories */ - -$file_path = dirname(__FILE__); - -// directory dir_variation91 with one sub-directory sub_dir11 and sub-sub-directory sub_dir111 -$dir_path1 = $file_path."/dir_variation91"; -$sub_dir11 = $dir_path1."/sub_dir11"; -$sub_dir111 = $sub_dir11."/sub_dir111"; - -// directory dir_variation92 with one sub-directory sub_dir21 -$dir_path2 = $file_path."/dir_variation92"; -$sub_dir21 = $dir_path2."/sub_dir21"; - -@mkdir($dir_path1); -@mkdir($dir_path2); -@mkdir($sub_dir11); -@mkdir($sub_dir111); -@mkdir($sub_dir21); - -// open the directory with valid paths -echo "\n-- With valid paths --\n"; -var_dump( dir("$dir_path1/sub_dir11/sub_dir111/..") ); -var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91") ); -var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir11/..") ); -var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/..") ); - -// open the directory with invalid path -echo "\n-- With invalid paths --\n"; -var_dump( dir("$dir_path1/sub_dir12/sub_dir111/..") ); -var_dump( dir("$dir_path2/sub_dir21/../dir_variation91") ); -var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir12/..") ); -var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..") ); - -echo "Done"; -?> ---CLEAN-- -<?php -$file_path = dirname(__FILE__); - -$dir_path1 = $file_path."/dir_variation91"; -$sub_dir11 = $dir_path1."/sub_dir11"; -$sub_dir111 = $sub_dir11."/sub_dir111"; -$dir_path2 = $file_path."/dir_variation92"; -$sub_dir21 = $dir_path2."/sub_dir21"; - -rmdir($sub_dir21); -rmdir($sub_dir111); -rmdir($sub_dir11); -rmdir($dir_path1); -rmdir($dir_path2); -?> ---EXPECTF-- -*** Testing dir() : checking with valid and invalid paths *** - --- With valid paths -- -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/.." - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91" - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir11/.." - ["handle"]=> - resource(%d) of type (stream) -} -object(Directory)#%d (2) { - ["path"]=> - string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/.." - ["handle"]=> - resource(%d) of type (stream) -} - --- With invalid paths -- - -Warning: dir(%sdir_variation91/sub_dir12/sub_dir111/..,%sdir_variation91/sub_dir12/sub_dir111/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation91/sub_dir12/sub_dir111/..): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation92/sub_dir21/../dir_variation91,%sdir_variation92/sub_dir21/../dir_variation91): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation92/sub_dir21/../dir_variation91): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..,%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): failed to open dir: %s in %s on line %d -bool(false) - -Warning: dir(%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..,%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d - -Warning: dir(%s/dir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): failed to open dir: %s in %s on line %d -bool(false) -Done diff --git a/ext/standard/tests/dir/opendir_error2-win32.phpt b/ext/standard/tests/dir/opendir_error2-win32.phpt deleted file mode 100644 index c3ecd35349..0000000000 --- a/ext/standard/tests/dir/opendir_error2-win32.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test opendir() function : error conditions - Non-existent directory ---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 a non-existent directory as $path argument to opendir() to test behaviour - */ - -echo "*** Testing opendir() : error conditions ***\n"; - -echo "\n-- Pass a non-existent absolute path: --\n"; -$path = dirname(__FILE__) . "/idonotexist"; -var_dump(opendir($path)); - -echo "\n-- Pass a non-existent relative path: --\n"; -chdir(dirname(__FILE__)); -var_dump(opendir('idonotexist')); -?> -===DONE=== ---EXPECTF-- -*** Testing opendir() : error conditions *** - --- Pass a non-existent absolute path: -- - -Warning: opendir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: opendir(%s/idonotexist): failed to open dir: %s in %s on line %d -bool(false) - --- Pass a non-existent relative path: -- - -Warning: opendir(idonotexist,idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d - -Warning: opendir(idonotexist): failed to open dir: %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/dir/opendir_variation1-win32.phpt b/ext/standard/tests/dir/opendir_variation1-win32.phpt deleted file mode 100644 index 9a75a5b6a7..0000000000 --- a/ext/standard/tests/dir/opendir_variation1-win32.phpt +++ /dev/null @@ -1,248 +0,0 @@ ---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 string, 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 string, resource given in %s on line %d -NULL -===DONE=== diff --git a/ext/standard/tests/dir/scandir_error2-win32.phpt b/ext/standard/tests/dir/scandir_error2-win32.phpt deleted file mode 100644 index 9920be747d..0000000000 --- a/ext/standard/tests/dir/scandir_error2-win32.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -Test scandir() function : error conditions - Non-existent directory ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) - * Description: List files & directories inside the specified path - * Source code: ext/standard/dir.c - */ - -/* - * Pass a directory that does not exist to scandir() to test error messages - */ - -echo "*** Testing scandir() : error conditions ***\n"; - -$directory = dirname(__FILE__) . '/idonotexist'; - -echo "\n-- Pass scandir() an absolute path that does not exist --\n"; -var_dump(scandir($directory)); - -echo "\n-- Pass scandir() a relative path that does not exist --\n"; -var_dump(scandir('/idonotexist')); -?> -===DONE=== ---EXPECTF-- -*** Testing scandir() : error conditions *** - --- Pass scandir() an absolute path that does not exist -- - -Warning: scandir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(%s/idonotexist): failed to open dir: %s in %s on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Pass scandir() a relative path that does not exist -- - -Warning: scandir(/idonotexist,/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(/idonotexist): failed to open dir: %s in %s on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation1-win32.phpt b/ext/standard/tests/dir/scandir_variation1-win32.phpt deleted file mode 100644 index a2b5bd4672..0000000000 --- a/ext/standard/tests/dir/scandir_variation1-win32.phpt +++ /dev/null @@ -1,289 +0,0 @@ ---TEST-- -Test scandir() function : usage variations - different data types as $dir arg ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) - * Description: List files & directories inside the specified path - * Source code: ext/standard/dir.c - */ - -/* - * Pass different data types as $dir argument to test behaviour of scandir() - */ - -echo "*** Testing scandir() : usage variations ***\n"; - -//get an unset variable -$unset_var = 10; -unset ($unset_var); - -// get a class -class classA -{ - public function __toString() { - return "Class A object"; - } -} - -// heredoc string -$heredoc = <<<EOT -hello world -EOT; - -// get a resource variable -$fp = fopen(__FILE__, "r"); - -// unexpected values to be passed to $dir 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*/ "string", - 'string', - $heredoc, - - // object data -/*22*/ new classA(), - - // 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 scandir() -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump( scandir($input) ); - $iterator++; -}; - -fclose($fp); -?> -===DONE=== ---EXPECTF-- -*** Testing scandir() : usage variations *** - --- Iteration 1 -- - -Warning: scandir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(0): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 2 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 3 -- - -Warning: scandir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(12345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 4 -- - -Warning: scandir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(-2345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 5 -- - -Warning: scandir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 6 -- - -Warning: scandir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(-10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 7 -- - -Warning: scandir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(123456789000): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 8 -- - -Warning: scandir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1.23456789E-9): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 9 -- - -Warning: scandir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(0.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 10 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 11 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 12 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 13 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 14 -- - -Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 15 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 16 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 17 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 18 -- - -Warning: scandir() expects parameter 1 to be a valid path, array given in %s on line %d -NULL - --- Iteration 19 -- - -Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 20 -- - -Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 21 -- - -Warning: scandir(hello world,hello world): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(hello world): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 22 -- - -Warning: scandir(Class A object,Class A object): The system cannot find the file specified. (code: 2) in %s on line %d - -Warning: scandir(Class A object): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Iteration 23 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 24 -- - -Warning: scandir(): Directory name cannot be empty in %s on line %d -bool(false) - --- Iteration 25 -- - -Warning: scandir() expects parameter 1 to be a valid path, resource given in %s on line %d -NULL -===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation6-win32.phpt b/ext/standard/tests/dir/scandir_variation6-win32.phpt deleted file mode 100644 index 040dc787cc..0000000000 --- a/ext/standard/tests/dir/scandir_variation6-win32.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -Test scandir() function : usage variations - Wildcards in directory path ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} -?> ---FILE-- -<?php -/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) - * Description: List files & directories inside the specified path - * Source code: ext/standard/dir.c - */ - -/* - * Pass a directory path using wildcards as $dir argument to test how scandir() behaves - */ - -echo "*** Testing scandir() : usage variations ***\n"; - -// create the temporary directories -$file_path = dirname(__FILE__); -$dir_path = $file_path . "/scandir_variation6"; -$sub_dir_path = $dir_path . "/sub_dir1"; - -mkdir($dir_path); -mkdir($sub_dir_path); - -// with different wildcard characters - -echo "\n-- Wildcard = '*' --\n"; -var_dump( scandir($file_path . "/scandir_var*") ); -var_dump( scandir($file_path . "/*") ); - -echo "\n-- Wildcard = '?' --\n"; -var_dump( scandir($dir_path . "/sub_dir?") ); -var_dump( scandir($dir_path . "/sub?dir1") ); - -?> -===DONE=== ---CLEAN-- -<?php -$dir_path = dirname(__FILE__) . "/scandir_variation6"; -$sub_dir_path = $dir_path . "/sub_dir1"; - -rmdir($sub_dir_path); -rmdir($dir_path); -?> ---EXPECTF-- -*** Testing scandir() : usage variations *** - --- Wildcard = '*' -- - -Warning: scandir(%s/scandir_var*,%s/scandir_var*): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_var*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - -Warning: scandir(%s/*,%s/*): No such file or directory in %s on line %d - -Warning: scandir(%s/*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - --- Wildcard = '?' -- - -Warning: scandir(%s/scandir_variation6/sub_dir?,%s/scandir_variation6/sub_dir?): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) - -Warning: scandir(%s/scandir_variation6/sub?dir1,%s/scandir_variation6/sub?dir1): No such file or directory in %s on line %d - -Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d - -Warning: scandir(): (errno %d): %s in %s on line %d -bool(false) -===DONE=== diff --git a/ext/standard/tests/file/007_error.phpt b/ext/standard/tests/file/007_error.phpt index a369c9d977..112beb3059 100644 --- a/ext/standard/tests/file/007_error.phpt +++ b/ext/standard/tests/file/007_error.phpt @@ -76,7 +76,7 @@ bool(false) Warning: fopen() expects at least 2 parameters, 0 given in %s on line %d bool(false) -Warning: fclose(): 5 is not a valid stream resource in %s on line %d +Warning: fclose(): %d is not a valid stream resource in %s on line %d bool(false) Warning: fclose() expects parameter 1 to be resource, string given in %s on line %d @@ -85,7 +85,7 @@ bool(false) Warning: fclose() expects exactly 1 parameter, 0 given in %s on line %d bool(false) -Warning: feof(): 5 is not a valid stream resource in %s on line %d +Warning: feof(): %d is not a valid stream resource in %s on line %d bool(false) Warning: feof() expects parameter 1 to be resource, string given in %s on line %d diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt index 9538c8ede8..fcd85489f3 100644 --- a/ext/standard/tests/file/bug22414.phpt +++ b/ext/standard/tests/file/bug22414.phpt @@ -7,7 +7,7 @@ output_handler= $php = getenv('TEST_PHP_EXECUTABLE'); $tmpfile = tempnam(__DIR__, 'phpt'); - $args = ' -n '; + $args = ' -n -dsafe_mode=off '; /* Regular Data Test */ passthru($php . $args . ' -r " echo \"HELLO\"; "'); diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt index 9dc663ae16..200e92ab43 100644 --- a/ext/standard/tests/file/disk_free_space_basic.phpt +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -37,7 +37,7 @@ echo "\n Free Space after writing to a file\n"; $space2 = disk_free_space($file_path.$dir); var_dump( $space2 ); -if( $space1 > $space2 ) +if($space1 > $space2 ) echo "\n Free Space Value Is Correct\n"; else echo "\n Free Space Value Is Incorrect\n"; diff --git a/ext/standard/tests/file/fgetss_error.phpt b/ext/standard/tests/file/fgetss_error.phpt index 3691e962e1..2b4ad68125 100644 --- a/ext/standard/tests/file/fgetss_error.phpt +++ b/ext/standard/tests/file/fgetss_error.phpt @@ -98,7 +98,7 @@ bool(false) Warning: fgetss() expects parameter 1 to be resource, object given in %s on line %d bool(false) -- Testing fgetss() with closed/unset file handle -- -Warning: fgetss(): 5 is not a valid stream resource in %s on line %d +Warning: fgetss(): %d is not a valid stream resource in %s on line %d bool(false) Warning: fgetss() expects parameter 1 to be resource, null given in %s on line %d diff --git a/ext/standard/tests/file/fputcsv_error.phpt b/ext/standard/tests/file/fputcsv_error.phpt index 9403cf446a..ebffd45425 100644 --- a/ext/standard/tests/file/fputcsv_error.phpt +++ b/ext/standard/tests/file/fputcsv_error.phpt @@ -48,7 +48,7 @@ Warning: fputcsv() expects at least 2 parameters, 0 given in %s on line %d NULL -- Testing fputcsv() with more than expected number of arguments -- -Warning: fputcsv() expects at most 4 parameters, 5 given in %s on line %d +Warning: fputcsv() expects parameter 5 to be string, resource given in %s on line %d NULL -- Testing fputcsv() with invalid arguments -- -- Iteration 1 -- diff --git a/ext/standard/tests/file/fputcsv_variation15.phpt b/ext/standard/tests/file/fputcsv_variation15.phpt new file mode 100755 index 0000000000..dc4a9e2dbd --- /dev/null +++ b/ext/standard/tests/file/fputcsv_variation15.phpt @@ -0,0 +1,107 @@ +--TEST-- +various fputcsv() functionality tests +--CREDITS-- +Lee Leathers <leeleathers@gmail.com> +--FILE-- +<?php + +$list = array ( + 0 => 'aaa,bbb', + 1 => 'aaa,"bbb"', + 2 => '"aaa","bbb"', + 3 => 'aaa,bbb', + 4 => '"aaa",bbb', + 5 => '"aaa", "bbb"', + 6 => ',', + 7 => 'aaa,', + 8 => ',"aaa"', + 9 => '"",""', + 10 => '"""""",', + 11 => '""""",aaa', + 12 => 'aaa,bbb ', + 13 => 'aaa,"bbb "', + 14 => 'aaa"aaa","bbb"bbb', + 15 => 'aaa"aaa""",bbb', + 16 => 'aaa,"/"bbb,ccc', + 17 => 'aaa"/"a","bbb"', + 18 => '"/"","aaa"', + 19 => '"/""",aaa', +); + +$file = dirname(__FILE__) . 'fgetcsv.csv'; +@unlink($file); + +$fp = fopen($file, "w"); +foreach ($list as $v) { + fputcsv($fp, explode(',', $v), ',', '"', '/'); +} +fclose($fp); + +$res = file($file); +foreach($res as &$val) +{ + $val = substr($val, 0, -1); +} +echo '$list = ';var_export($res);echo ";\n"; + +$fp = fopen($file, "r"); +$res = array(); +while($l=fgetcsv($fp, 0, ',', '"', '/')) +{ + $res[] = join(',',$l); +} +fclose($fp); + +echo '$list = ';var_export($res);echo ";\n"; + +@unlink($file); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +$list = array ( + 0 => 'aaa,bbb', + 1 => 'aaa,"""bbb"""', + 2 => '"""aaa""","""bbb"""', + 3 => 'aaa,bbb', + 4 => '"""aaa""",bbb', + 5 => '"""aaa"""," ""bbb"""', + 6 => ',', + 7 => 'aaa,', + 8 => ',"""aaa"""', + 9 => '"""""",""""""', + 10 => '"""""""""""""",', + 11 => '"""""""""""",aaa', + 12 => 'aaa,"bbb "', + 13 => 'aaa,"""bbb """', + 14 => '"aaa""aaa""","""bbb""bbb"', + 15 => '"aaa""aaa""""""",bbb', + 16 => 'aaa,"""/"bbb",ccc', + 17 => '"aaa""/"a""","""bbb"""', + 18 => '"""/"""","""aaa"""', + 19 => '"""/"""""",aaa', +); +$list = array ( + 0 => 'aaa,bbb', + 1 => 'aaa,"bbb"', + 2 => '"aaa","bbb"', + 3 => 'aaa,bbb', + 4 => '"aaa",bbb', + 5 => '"aaa", "bbb"', + 6 => ',', + 7 => 'aaa,', + 8 => ',"aaa"', + 9 => '"",""', + 10 => '"""""",', + 11 => '""""",aaa', + 12 => 'aaa,bbb ', + 13 => 'aaa,"bbb "', + 14 => 'aaa"aaa","bbb"bbb', + 15 => 'aaa"aaa""",bbb', + 16 => 'aaa,"/"bbb,ccc', + 17 => 'aaa"/"a","bbb"', + 18 => '"/"","aaa"', + 19 => '"/""",aaa', +); +===DONE=== diff --git a/ext/standard/tests/file/ftruncate_error.phpt b/ext/standard/tests/file/ftruncate_error.phpt index a28095bc2d..254ad7688d 100644 --- a/ext/standard/tests/file/ftruncate_error.phpt +++ b/ext/standard/tests/file/ftruncate_error.phpt @@ -114,7 +114,7 @@ Warning: ftruncate() expects parameter 1 to be resource, object given in %s on l bool(false) -- Testing ftruncate() with closed/unset file handle -- -Warning: ftruncate(): 5 is not a valid stream resource in %s on line %d +Warning: ftruncate(): %d is not a valid stream resource in %s on line %d bool(false) int(36) diff --git a/ext/standard/tests/file/parse_ini_file.phpt b/ext/standard/tests/file/parse_ini_file.phpt index dab07e56e7..db14c7a9b4 100644 --- a/ext/standard/tests/file/parse_ini_file.phpt +++ b/ext/standard/tests/file/parse_ini_file.phpt @@ -57,15 +57,15 @@ Non_alpha4 = % Non_alpha5 = <> Non_alpha6 = @ Non_alpha7 = # -Non_alpha8 = ^ -Non_alpha9 = - -Non_alpha10 = : -Non_alpha11 = ? -Non_alpha12 = / -Non_alpha13 = \ +Non_alpha8 = - +Non_alpha9 = : +Non_alpha10 = ? +Non_alpha11 = / +Non_alpha12 = \ ;These chars have a special meaning when used in the value, ; hence parser throws an error -;Non_alpha14 = & +;Non_alpha13 = & +;Non_alpha14 = ^ ;Non_alpha15 = {} ;Non_alpha16 = | ;Non_alpha17 = ~ @@ -249,12 +249,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * @@ -385,12 +384,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * diff --git a/ext/standard/tests/general_functions/boolval.phpt b/ext/standard/tests/general_functions/boolval.phpt new file mode 100644 index 0000000000..9d0eac4ebd --- /dev/null +++ b/ext/standard/tests/general_functions/boolval.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing boolval() +--FILE-- +<?php + var_dump(boolval(false)); + var_dump(boolval(NULL)); + var_dump(boolval("")); + var_dump(boolval(0)); + var_dump(boolval(array())); + + var_dump(boolval(true)); + var_dump(boolval("abc")); + var_dump(boolval(0.5)); + var_dump(boolval(100)); + var_dump(boolval(new stdClass())); + var_dump(boolval(STDIN)); +?> +--EXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/general_functions/floatval.phpt b/ext/standard/tests/general_functions/floatval.phpt index b427bda7d5..9b7a3281e4 100644 --- a/ext/standard/tests/general_functions/floatval.phpt +++ b/ext/standard/tests/general_functions/floatval.phpt @@ -157,8 +157,8 @@ float(-5000000) *** Testing floatval() on non floating types *** float(-2147483648) float(2147483648) -float(5) -float(6) +float(%d) +float(%d) float(0) float(1) float(-1300) @@ -175,8 +175,8 @@ float(0) *** Testing doubleval() on non floating types *** float(-2147483648) float(2147483648) -float(5) -float(6) +float(%d) +float(%d) float(0) float(1) float(-1300) diff --git a/ext/standard/tests/general_functions/gettype_settype_basic.phpt b/ext/standard/tests/general_functions/gettype_settype_basic.phpt index d6fb0d495b..d1fd4095be 100644 --- a/ext/standard/tests/general_functions/gettype_settype_basic.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_basic.phpt @@ -232,11 +232,11 @@ int(0) string(7) "integer" -- Iteration 12 -- bool(true) -int(5) +int(%d) string(7) "integer" -- Iteration 13 -- bool(true) -int(6) +int(%d) string(7) "integer" -- Iteration 14 -- 8: Object of class point could not be converted to int @@ -291,11 +291,11 @@ int(0) string(7) "integer" -- Iteration 12 -- bool(true) -int(5) +int(%d) string(7) "integer" -- Iteration 13 -- bool(true) -int(6) +int(%d) string(7) "integer" -- Iteration 14 -- 8: Object of class point could not be converted to int @@ -350,11 +350,11 @@ float(0) string(6) "double" -- Iteration 12 -- bool(true) -float(5) +float(%d) string(6) "double" -- Iteration 13 -- bool(true) -float(6) +float(%d) string(6) "double" -- Iteration 14 -- 8: Object of class point could not be converted to double @@ -409,11 +409,11 @@ float(0) string(6) "double" -- Iteration 12 -- bool(true) -float(5) +float(%d) string(6) "double" -- Iteration 13 -- bool(true) -float(6) +float(%d) string(6) "double" -- Iteration 14 -- 8: Object of class point could not be converted to double @@ -610,12 +610,12 @@ string(6) "string" -- Iteration 12 -- 2: settype(): Cannot convert to resource type bool(false) -resource(5) of type (stream) +resource(%d) of type (stream) string(8) "resource" -- Iteration 13 -- 2: settype(): Cannot convert to resource type bool(false) -resource(6) of type (stream) +resource(%d) of type (stream) string(8) "resource" -- Iteration 14 -- 2: settype(): Cannot convert to resource type @@ -716,14 +716,14 @@ string(5) "array" bool(true) array(1) { [0]=> - resource(5) of type (stream) + resource(%d) of type (stream) } string(5) "array" -- Iteration 13 -- bool(true) array(1) { [0]=> - resource(6) of type (stream) + resource(%d) of type (stream) } string(5) "array" -- Iteration 14 -- @@ -824,14 +824,14 @@ string(6) "object" bool(true) object(stdClass)#2 (1) { ["scalar"]=> - resource(5) of type (stream) + resource(%d) of type (stream) } string(6) "object" -- Iteration 13 -- bool(true) object(stdClass)#2 (1) { ["scalar"]=> - resource(6) of type (stream) + resource(%d) of type (stream) } string(6) "object" -- Iteration 14 -- @@ -893,11 +893,11 @@ string(6) "string" string(6) "string" -- Iteration 12 -- bool(true) -string(14) "Resource id #5" +string(14) "Resource id #%d" string(6) "string" -- Iteration 13 -- bool(true) -string(14) "Resource id #6" +string(14) "Resource id #%d" string(6) "string" -- Iteration 14 -- bool(true) diff --git a/ext/standard/tests/general_functions/parse_ini_string_001.phpt b/ext/standard/tests/general_functions/parse_ini_string_001.phpt index e135210aa6..c5e70cb900 100644 --- a/ext/standard/tests/general_functions/parse_ini_string_001.phpt +++ b/ext/standard/tests/general_functions/parse_ini_string_001.phpt @@ -55,15 +55,15 @@ Non_alpha4 = % Non_alpha5 = <> Non_alpha6 = @ Non_alpha7 = # -Non_alpha8 = ^ -Non_alpha9 = - -Non_alpha10 = : -Non_alpha11 = ? -Non_alpha12 = / -Non_alpha13 = \ +Non_alpha8 = - +Non_alpha9 = : +Non_alpha10 = ? +Non_alpha11 = / +Non_alpha12 = \ ;These chars have a special meaning when used in the value, ; hence parser throws an error -;Non_alpha14 = & +;Non_alpha13 = & +;Non_alpha14 = ^ ;Non_alpha15 = {} ;Non_alpha16 = | ;Non_alpha17 = ~ @@ -239,12 +239,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * @@ -375,12 +374,11 @@ Array [Non_alpha5] => <> [Non_alpha6] => @ [Non_alpha7] => # - [Non_alpha8] => ^ - [Non_alpha9] => - - [Non_alpha10] => : - [Non_alpha11] => ? - [Non_alpha12] => / - [Non_alpha13] => \ + [Non_alpha8] => - + [Non_alpha9] => : + [Non_alpha10] => ? + [Non_alpha11] => / + [Non_alpha12] => \ [Non_alpha1_quotes] => ; [Non_alpha2_quotes] => + [Non_alpha3_quotes] => * diff --git a/ext/standard/tests/general_functions/print_r.phpt b/ext/standard/tests/general_functions/print_r.phpt index 81a523ad0b..19e71fbfd7 100644 --- a/ext/standard/tests/general_functions/print_r.phpt +++ b/ext/standard/tests/general_functions/print_r.phpt @@ -1484,13 +1484,13 @@ object_class Object *** Testing print_r() on resources *** -- Iteration 1 -- -Resource id #5 -Resource id #5 -Resource id #5 +Resource id #%d +Resource id #%d +Resource id #%d -- Iteration 2 -- -Resource id #6 -Resource id #6 -Resource id #6 +Resource id #%d +Resource id #%d +Resource id #%d *** Testing print_r() on different combinations of scalar and non-scalar variables *** diff --git a/ext/standard/tests/general_functions/strval.phpt b/ext/standard/tests/general_functions/strval.phpt index b92be41ef4..372ac6701e 100644 --- a/ext/standard/tests/general_functions/strval.phpt +++ b/ext/standard/tests/general_functions/strval.phpt @@ -279,9 +279,9 @@ string(0) "" -- Iteration 1 -- string(6) "Object" -- Iteration 2 -- -string(14) "Resource id #5" +string(14) "Resource id #%d" -- Iteration 3 -- -string(14) "Resource id #6" +string(14) "Resource id #%d" -- Iteration 4 -- Notice: Array to string conversion in %sstrval.php on line %d diff --git a/ext/standard/tests/general_functions/type.phpt b/ext/standard/tests/general_functions/type.phpt index 98eccbbda7..51654b1859 100644 --- a/ext/standard/tests/general_functions/type.phpt +++ b/ext/standard/tests/general_functions/type.phpt @@ -105,9 +105,9 @@ int(0) bool(true) int(0) bool(true) -int(5) +int(%d) bool(true) -int(6) +int(%d) string(54) "Object of class stdClass could not be converted to int" bool(true) int(%d) @@ -128,9 +128,9 @@ float(0) bool(true) float(0) bool(true) -float(5) +float(%d) bool(true) -float(6) +float(%d) string(57) "Object of class stdClass could not be converted to double" bool(true) float(%d) diff --git a/ext/standard/tests/general_functions/var_dump.phpt b/ext/standard/tests/general_functions/var_dump.phpt index 09e9f3b99e..c47227141b 100644 --- a/ext/standard/tests/general_functions/var_dump.phpt +++ b/ext/standard/tests/general_functions/var_dump.phpt @@ -844,9 +844,9 @@ object(object_class)#13 (8) { *** Testing var_dump() on resources *** -- Iteration 1 -- -resource(5) of type (stream) +resource(%d) of type (stream) -- Iteration 2 -- -resource(6) of type (stream) +resource(%d) of type (stream) *** Testing var_dump() on different combinations of scalar and non-scalar variables *** @@ -1227,9 +1227,9 @@ array(4) { } array(2) { [0]=> - resource(5) of type (stream) + resource(%d) of type (stream) [1]=> - resource(6) of type (stream) + resource(%d) of type (stream) } array(9) { [0]=> diff --git a/ext/standard/tests/mail/bug51604.phpt b/ext/standard/tests/mail/bug51604.phpt index a657021025..988849c4e1 100644 --- a/ext/standard/tests/mail/bug51604.phpt +++ b/ext/standard/tests/mail/bug51604.phpt @@ -11,7 +11,7 @@ if(substr(PHP_OS, 0, 3) == "WIN") --FILE-- <?php // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = "KHeaders\n\n\n\n\n"; @@ -27,7 +27,7 @@ unlink($outFile); ===DONE=== --EXPECT-- bool(true) -To: user@company.com +To: user@example.com Subject: Test Subject KHeaders diff --git a/ext/standard/tests/mail/mail_basic.phpt b/ext/standard/tests/mail/mail_basic.phpt index fecb50f32c..70f32df40f 100644 --- a/ext/standard/tests/mail/mail_basic.phpt +++ b/ext/standard/tests/mail/mail_basic.phpt @@ -20,7 +20,7 @@ echo "*** Testing mail() : basic functionality ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = 'KHeaders'; @@ -45,7 +45,7 @@ unlink($outFile); *** Testing mail() : basic functionality *** -- All Mail Content Parameters -- bool(true) -To: user@company.com +To: user@example.com Subject: Test Subject KHeaders @@ -53,7 +53,7 @@ A Message -- Mandatory Parameters -- bool(true) -To: user@company.com +To: user@example.com Subject: Test Subject A Message diff --git a/ext/standard/tests/mail/mail_basic2.phpt b/ext/standard/tests/mail/mail_basic2.phpt index 8967d18c4f..60ad009190 100644 --- a/ext/standard/tests/mail/mail_basic2.phpt +++ b/ext/standard/tests/mail/mail_basic2.phpt @@ -20,7 +20,7 @@ echo "*** Testing mail() : basic functionality ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = 'KHeaders'; @@ -40,7 +40,7 @@ unlink($outFile); *** Testing mail() : basic functionality *** -- extra parameters -- bool(true) -%w1%wTo: user@company.com +%w1%wTo: user@example.com %w2%wSubject: Test Subject %w3%wKHeaders %w4%w diff --git a/ext/standard/tests/mail/mail_basic3.phpt b/ext/standard/tests/mail/mail_basic3.phpt index 58eae0379e..3e648e5cac 100644 --- a/ext/standard/tests/mail/mail_basic3.phpt +++ b/ext/standard/tests/mail/mail_basic3.phpt @@ -19,7 +19,7 @@ echo "*** Testing mail() : basic functionality ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; diff --git a/ext/standard/tests/mail/mail_basic4.phpt b/ext/standard/tests/mail/mail_basic4.phpt index 9ecc886aec..de2407a740 100644 --- a/ext/standard/tests/mail/mail_basic4.phpt +++ b/ext/standard/tests/mail/mail_basic4.phpt @@ -19,7 +19,7 @@ echo "*** Testing mail() : basic functionality ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; diff --git a/ext/standard/tests/mail/mail_basic5.phpt b/ext/standard/tests/mail/mail_basic5.phpt index 7e42ccb833..8d755ebb86 100644 --- a/ext/standard/tests/mail/mail_basic5.phpt +++ b/ext/standard/tests/mail/mail_basic5.phpt @@ -19,7 +19,7 @@ echo "*** Testing mail() : basic functionality ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; diff --git a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt index 3c4dd88a5b..fc50498347 100644 --- a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt @@ -22,7 +22,7 @@ max_execution_time = 120 error_reporting(E_ALL & ~E_STRICT); ini_set("SMTP", "localhost"); ini_set("smtp_port", 25); -ini_set("sendmail_from", "user@company.com"); +ini_set("sendmail_from", "user@example.com"); echo "*** Testing mail() : basic functionality ***\n"; require_once(dirname(__FILE__).'/mail_include.inc'); diff --git a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt index d7bae62a0f..892d92391e 100644 --- a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt @@ -32,7 +32,7 @@ bool mail ( string \$to , string \$subject , string \$message [, string \$additi Send an email message HERE; -$extra_headers = "from: user@company.com"; +$extra_headers = "from: user@example.com"; $res = mail($to, $subject, $message, $extra_headers); diff --git a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt index 86b57eb813..1caa68c068 100644 --- a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt @@ -32,7 +32,7 @@ bool mail ( string \$to , string \$subject , string \$message [, string \$additi Send an email message HERE; -$extra_headers = "FRom: user@company.com"; +$extra_headers = "FRom: user@example.com"; $res = mail($to, $subject, $message, $extra_headers); diff --git a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt index f4a9d466bc..c8e45242e2 100644 --- a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt @@ -32,7 +32,7 @@ bool mail ( string \$to , string \$subject , string \$message [, string \$additi Send an email message HERE; -$extra_headers = "from: user@company.com"; +$extra_headers = "from: user@example.com"; $extra_parameters = "addons"; // should be ignored $res = mail($to, $subject, $message, $extra_headers, $extra_parameters); diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt new file mode 100644 index 0000000000..86346ec307 --- /dev/null +++ b/ext/standard/tests/mail/mail_log.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test mail() function : mail.log ini setting +--INI-- +sendmail_path=tee /tmp/mail.out >/dev/null +mail.log = /tmp/mail.log +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +date_default_timezone_set("UTC"); + +$logfile = ini_get("mail.log"); +if (file_exists($logfile)) { + unlink($logfile); +} +touch($logfile); +clearstatcache(); + +$to = "test@example.com"; +$subject = "mail.log test"; +$message = "Testing mail.log"; +$headers = "X-Test: 1"; + +var_dump(filesize($logfile) == 0); +clearstatcache(); + +var_dump(mail($to, $subject, $message, $headers)); + +var_dump(filesize($logfile) > 0); +clearstatcache(); + +echo file_get_contents($logfile); +?> +Done +--CLEAN-- +<?php +unlink("/tmp/mail.log"); +unlink("/tmp/mail.out"); +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) +[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1 +Done diff --git a/ext/standard/tests/mail/mail_variation1.phpt b/ext/standard/tests/mail/mail_variation1.phpt index bf37bf41e6..a8eb6bec79 100644 --- a/ext/standard/tests/mail/mail_variation1.phpt +++ b/ext/standard/tests/mail/mail_variation1.phpt @@ -18,7 +18,7 @@ if(substr(PHP_OS, 0, 3) == "WIN") echo "*** Testing mail() : variation ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; var_dump( mail($to, $subject, $message) ); diff --git a/ext/standard/tests/mail/mail_variation2.phpt b/ext/standard/tests/mail/mail_variation2.phpt index c16c2706a7..f0e44241b1 100644 --- a/ext/standard/tests/mail/mail_variation2.phpt +++ b/ext/standard/tests/mail/mail_variation2.phpt @@ -21,7 +21,7 @@ echo "*** Testing mail() : basic functionality ***\n"; // Initialise all required variables -$to = 'user@company.com'; +$to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $outFile = "/tmp/php_test_mailVariation2.out"; @@ -36,7 +36,7 @@ unlink($outFile); --EXPECTF-- *** Testing mail() : basic functionality *** bool(true) -%w1%wTo: user@company.com +%w1%wTo: user@example.com %w2%wSubject: Test Subject %w3%w %w4%wA Message diff --git a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt index b81f3af9d2..dd7fd937e2 100644 --- a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt @@ -21,7 +21,7 @@ max_execution_time = 120 error_reporting(E_ALL & ~E_STRICT); ini_set("SMTP", "localhost"); ini_set("smtp_port", 2525); -ini_set("sendmail_from", "user@company.com"); +ini_set("sendmail_from", "user@example.com"); echo "*** Testing mail() : basic functionality ***\n"; require_once(dirname(__FILE__).'/mail_include.inc'); diff --git a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt index 6ae06bb202..817cc36af4 100644 --- a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt @@ -21,7 +21,7 @@ max_execution_time = 120 error_reporting(E_ALL & ~E_STRICT); ini_set("SMTP", "localplace"); ini_set("smtp_port", 25); -ini_set("sendmail_from", "user@company.com"); +ini_set("sendmail_from", "user@example.com"); echo "*** Testing mail() : basic functionality ***\n"; require_once(dirname(__FILE__).'/mail_include.inc'); diff --git a/ext/standard/tests/network/ip2long_variation1.phpt b/ext/standard/tests/network/ip2long_variation1.phpt index f87282ae75..b228c9bd14 100644 --- a/ext/standard/tests/network/ip2long_variation1.phpt +++ b/ext/standard/tests/network/ip2long_variation1.phpt @@ -1,10 +1,5 @@ --TEST-- -Test ip2long() function : usage variation ---SKIPIF-- -<?php -if(substr(PHP_OS, 0, 3) == "WIN") - die("skip. Windows is more compliant (like 0 for localhost, etc.)"); -?> +Test ip2long() function : usage variation 1 --FILE-- <?php /* Prototype : int ip2long(string ip_address) diff --git a/ext/standard/tests/network/ip2long_variation2.phpt b/ext/standard/tests/network/ip2long_variation2.phpt new file mode 100644 index 0000000000..752956320c --- /dev/null +++ b/ext/standard/tests/network/ip2long_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test ip2long() function : usage variation 2, 32 bit +--SKIPIF-- +<?php if(PHP_INT_SIZE != 4) {die('skip 32 bit only');} ?> +--FILE-- +<?php +/* Prototype : int ip2long(string ip_address) + * Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address + * Source code: ext/standard/basic_functions.c + * Alias to functions: + */ + +$ips = array( + "1.1.011.011", + "127.0.0.1", + "1.1.071.071", + "0.0.0.0", + "1.1.081.081", + "192.168.0.0", + "256.0.0.1", + "192.168.0xa.5", +); + +foreach($ips as $ip) { + var_dump(ip2long($ip)); +} + +?> +===DONE=== +--EXPECT-- +bool(false) +int(2130706433) +bool(false) +int(0) +bool(false) +int(-1062731776) +bool(false) +bool(false) +===DONE=== diff --git a/ext/standard/tests/network/ip2long_variation2_x64.phpt b/ext/standard/tests/network/ip2long_variation2_x64.phpt new file mode 100644 index 0000000000..a6fde5bdd9 --- /dev/null +++ b/ext/standard/tests/network/ip2long_variation2_x64.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test ip2long() function : usage variation 2, 64 bit +--SKIPIF-- +<?php +/* from man inet_pton : + All numbers supplied as ``parts'' in a `.' notation may be decimal, octal, or hexadecimal, as specified + in the C language (i.e., a leading 0x or 0X implies hexadecimal; otherwise, a leading 0 implies octal; + otherwise, the number is interpreted as decimal). +*/ +if(PHP_OS == 'Darwin') die("skip - inet_pton behaves differently on Darwin"); +if(PHP_INT_SIZE != 8) {die('skip 64 bit only');} +?> +--FILE-- +<?php +/* Prototype : int ip2long(string ip_address) + * Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address + * Source code: ext/standard/basic_functions.c + * Alias to functions: + */ + +$ips = array( + "1.1.011.011", + "127.0.0.1", + "1.1.071.071", + "0.0.0.0", + "1.1.081.081", + "192.168.0.0", + "256.0.0.1", + "192.168.0xa.5", +); + +foreach($ips as $ip) { + var_dump(ip2long($ip)); +} + +?> +===DONE=== +--EXPECT-- +bool(false) +int(2130706433) +bool(false) +int(0) +bool(false) +int(3232235520) +bool(false) +bool(false) +===DONE=== diff --git a/ext/standard/tests/network/setcookie.phpt b/ext/standard/tests/network/setcookie.phpt new file mode 100644 index 0000000000..bf04ec78de --- /dev/null +++ b/ext/standard/tests/network/setcookie.phpt @@ -0,0 +1,70 @@ +--TEST-- +setcookie() tests +--DESCRIPTION-- +--INI-- +date.timezone=UTC +--FILE-- +<?php +setcookie('name'); +setcookie('name', 'value'); +setcookie('name', 'space value'); +setcookie('name', 'value', 0); +setcookie('name', 'value', $tsp = time() + 5); +setcookie('name', 'value', $tsn = time() - 6); +setcookie('name', 'value', $tsc = time()); +setcookie('name', 'value', 0, '/path/'); +setcookie('name', 'value', 0, '', 'domain.tld'); +setcookie('name', 'value', 0, '', '', TRUE); +setcookie('name', 'value', 0, '', '', FALSE, TRUE); + + +$expected = array( + 'Set-Cookie: name=', + 'Set-Cookie: name=value', + 'Set-Cookie: name=space+value', + 'Set-Cookie: name=value', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsp).' GMT; Max-Age=5', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsn).' GMT; Max-Age=-6', + 'Set-Cookie: name=value; expires='.date('D, d-M-Y H:i:s', $tsc).' GMT; Max-Age=0', + 'Set-Cookie: name=value; path=/path/', + 'Set-Cookie: name=value; domain=domain.tld', + 'Set-Cookie: name=value; secure', + 'Set-Cookie: name=value; httponly' +); + +$headers = headers_list(); +if (($i = count($expected)) > count($headers)) +{ + echo "Less headers are being sent than expected - aborting"; + return; +} + +do +{ + if (strncmp(current($headers), 'Set-Cookie:', 11) !== 0) + { + continue; + } + + if (current($headers) === current($expected)) + { + $i--; + } + else + { + echo "Header mismatch:\n\tExpected: " + .current($expected) + ."\n\tReceived: ".current($headers)."\n"; + } + + next($expected); +} +while (next($headers) !== FALSE); + +echo ($i === 0) + ? 'OK' + : 'A total of '.$i.' errors found.'; +--EXPECTHEADERS-- + +--EXPECT-- +OK
\ No newline at end of file diff --git a/ext/standard/tests/password/password_bcrypt_errors.phpt b/ext/standard/tests/password/password_bcrypt_errors.phpt new file mode 100644 index 0000000000..2548c9accb --- /dev/null +++ b/ext/standard/tests/password/password_bcrypt_errors.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test error operation of password_hash() with bcrypt hashing +--FILE-- +<?php +//-=-=-=- + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 3))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => 32))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => "foo"))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => "123456789012345678901"))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("salt" => 123))); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, array("cost" => "foo"))); + +?> +--EXPECTF-- +Warning: password_hash(): Invalid bcrypt cost parameter specified: 3 in %s on line %d +NULL + +Warning: password_hash(): Invalid bcrypt cost parameter specified: 32 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 3 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 21 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 3 expecting 22 in %s on line %d +NULL + +Warning: password_hash(): Invalid bcrypt cost parameter specified: 0 in %s on line %d +NULL + + diff --git a/ext/standard/tests/password/password_get_info.phpt b/ext/standard/tests/password/password_get_info.phpt new file mode 100644 index 0000000000..4c8dc04ff8 --- /dev/null +++ b/ext/standard/tests/password/password_get_info.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test normal operation of password_get_info() +--FILE-- +<?php +//-=-=-=- +// Test Bcrypt +var_dump(password_get_info('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y')); +// Test Bcrypt Cost +var_dump(password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y')); +// Test Bcrypt Invalid Length +var_dump(password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100')); +// Test Non-Bcrypt +var_dump(password_get_info('$1$rasmusle$rISCgZzpwk3UhDidwXvin0')); + +echo "OK!"; +?> +--EXPECT-- +array(3) { + ["algo"]=> + int(1) + ["algoName"]=> + string(6) "bcrypt" + ["options"]=> + array(1) { + ["cost"]=> + int(10) + } +} +array(3) { + ["algo"]=> + int(1) + ["algoName"]=> + string(6) "bcrypt" + ["options"]=> + array(1) { + ["cost"]=> + int(11) + } +} +array(3) { + ["algo"]=> + int(0) + ["algoName"]=> + string(7) "unknown" + ["options"]=> + array(0) { + } +} +array(3) { + ["algo"]=> + int(0) + ["algoName"]=> + string(7) "unknown" + ["options"]=> + array(0) { + } +} +OK! diff --git a/ext/standard/tests/password/password_get_info_error.phpt b/ext/standard/tests/password/password_get_info_error.phpt new file mode 100644 index 0000000000..af676744c8 --- /dev/null +++ b/ext/standard/tests/password/password_get_info_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test error operation of password_get_info() +--FILE-- +<?php +//-=-=-=- +var_dump(password_get_info()); +var_dump(password_get_info(array())); + +echo "OK!"; +?> +--EXPECTF-- +Warning: password_get_info() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: password_get_info() expects parameter 1 to be string, array given in %s on line %d +NULL +OK! diff --git a/ext/standard/tests/password/password_hash.phpt b/ext/standard/tests/password/password_hash.phpt new file mode 100644 index 0000000000..f59d3d5e48 --- /dev/null +++ b/ext/standard/tests/password/password_hash.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test normal operation of password_hash() +--FILE-- +<?php +//-=-=-=- + +var_dump(strlen(password_hash("foo", PASSWORD_BCRYPT))); + +$hash = password_hash("foo", PASSWORD_BCRYPT); + +var_dump($hash === crypt("foo", $hash)); + +var_dump(password_hash("rasmuslerdorf", PASSWORD_BCRYPT, array("cost" => 7, "salt" => "usesomesillystringforsalt"))); + +var_dump(password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0)))); + +echo "OK!"; +?> +--EXPECT-- +int(60) +bool(true) +string(60) "$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi" +string(60) "$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y" +OK! + diff --git a/ext/standard/tests/password/password_hash_error.phpt b/ext/standard/tests/password/password_hash_error.phpt new file mode 100644 index 0000000000..952250cb30 --- /dev/null +++ b/ext/standard/tests/password/password_hash_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test error operation of password_hash() +--FILE-- +<?php +//-=-=-=- + +var_dump(password_hash()); + +var_dump(password_hash("foo")); + +var_dump(password_hash("foo", array())); + +var_dump(password_hash("foo", 19, new StdClass)); + +var_dump(password_hash("foo", PASSWORD_BCRYPT, "baz")); + +var_dump(password_hash(array(), PASSWORD_BCRYPT)); + +var_dump(password_hash("123", PASSWORD_BCRYPT, array("salt" => array()))); + +/* Non-string salt, checking for memory leaks */ +var_dump(password_hash('123', PASSWORD_BCRYPT, array('salt' => 1234))); + +?> +--EXPECTF-- +Warning: password_hash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: password_hash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: password_hash() expects parameter 2 to be long, array given in %s on line %d +NULL + +Warning: password_hash(): Unknown password hashing algorithm: 19 in %s on line %d +NULL + +Warning: password_hash() expects parameter 3 to be array, string given in %s on line %d +NULL + +Warning: password_hash() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: password_hash(): Non-string salt parameter supplied in %s on line %d +NULL + +Warning: password_hash(): Provided salt is too short: 4 expecting 22 in %s on line %d +NULL diff --git a/ext/standard/tests/password/password_needs_rehash.phpt b/ext/standard/tests/password/password_needs_rehash.phpt new file mode 100644 index 0000000000..734729e63d --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test normal operation of password_needs_rehash() +--FILE-- +<?php +//-=-=-=- + +// Invalid Hash, always rehash +var_dump(password_needs_rehash('', PASSWORD_BCRYPT)); + +// Valid, as it's an unknown algorithm +var_dump(password_needs_rehash('', 0)); + +// Valid with cost the same +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10))); + +// Valid with cost the same, additional params +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10, 'foo' => 3))); + +// Invalid, different (lower) cost +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 09))); + +// Invalid, different (higher) cost +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 11))); + +// Valid with cost the default +$cost = str_pad(PASSWORD_BCRYPT_DEFAULT_COST, 2, '0', STR_PAD_LEFT); +var_dump(password_needs_rehash('$2y$'.$cost.'$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT)); + +// Should Issue Needs Rehash, Since Foo is cast to 0... +var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 'foo'))); + + + +echo "OK!"; +?> +--EXPECT-- +bool(true) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +OK! diff --git a/ext/standard/tests/password/password_needs_rehash_error.phpt b/ext/standard/tests/password/password_needs_rehash_error.phpt new file mode 100644 index 0000000000..e25ef8db3f --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test error operation of password_needs_rehash() +--FILE-- +<?php +//-=-=-=- +var_dump(password_needs_rehash()); + +var_dump(password_needs_rehash('')); + +var_dump(password_needs_rehash('', "foo")); + +var_dump(password_needs_rehash(array(), 1)); + +var_dump(password_needs_rehash("", 1, "foo")); + +echo "OK!"; +?> +--EXPECTF-- +Warning: password_needs_rehash() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: password_needs_rehash() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 2 to be long, string given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: password_needs_rehash() expects parameter 3 to be array, string given in %s on line %d +NULL +OK! diff --git a/ext/standard/tests/password/password_verify.phpt b/ext/standard/tests/password/password_verify.phpt new file mode 100644 index 0000000000..e7ecc7edd3 --- /dev/null +++ b/ext/standard/tests/password/password_verify.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test normal operation of password_verify) +--FILE-- +<?php +//-=-=-=- + +var_dump(password_verify(123, 123)); + +var_dump(password_verify("foo", '$2a$07$usesomesillystringforsalt$')); + +var_dump(password_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); + +var_dump(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); +echo "OK!"; +?> +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(true) +OK! diff --git a/ext/standard/tests/password/password_verify_error.phpt b/ext/standard/tests/password/password_verify_error.phpt new file mode 100644 index 0000000000..3e653fa04e --- /dev/null +++ b/ext/standard/tests/password/password_verify_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test error operation of password_verify() +--FILE-- +<?php +//-=-=-=- + +var_dump(password_verify()); + +var_dump(password_verify("foo")); + +?> +--EXPECTF-- +Warning: password_verify() expects exactly 2 parameters, 0 given in %s on line %d +bool(false) + +Warning: password_verify() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt index 747e0196f1..7d441582ee 100644 --- a/ext/standard/tests/php_ini_loaded_file.phpt +++ b/ext/standard/tests/php_ini_loaded_file.phpt @@ -10,5 +10,5 @@ precision=12 <?php var_dump(php_ini_loaded_file()); ?> ---EXPECTF-- -string(%d) "%sphp.ini" +--EXPECTREGEX-- +string\(\d+\) ".*php\.ini"|bool\(false\) diff --git a/ext/standard/tests/php_logo_guid.phpt b/ext/standard/tests/php_logo_guid.phpt deleted file mode 100644 index c644b2893b..0000000000 --- a/ext/standard/tests/php_logo_guid.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Check the output of the php_logo_guid() function ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- -<?php -echo php_logo_guid(); -?> ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 - diff --git a/ext/standard/tests/php_real_logo_guid.phpt b/ext/standard/tests/php_real_logo_guid.phpt deleted file mode 100644 index a9fa7d35d5..0000000000 --- a/ext/standard/tests/php_real_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Testing the undocumented function php_real_logo_guid() ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- -<?php -echo php_real_logo_guid(); -?> ---EXPECT-- -PHPE9568F34-D428-11d2-A769-00AA001ACF42 diff --git a/ext/standard/tests/strings/bug61038.phpt b/ext/standard/tests/strings/bug61038.phpt new file mode 100644 index 0000000000..7130804fa4 --- /dev/null +++ b/ext/standard/tests/strings/bug61038.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #61038: unpack("a5", "str\0\0") does not work as expected +--FILE-- +<?php +var_dump(unpack("a4", "str\0\0")); +var_dump(unpack("a5", "str\0\0")); +var_dump(unpack("a6", "str\0\0")); +var_dump(unpack("a*", "str\0\0")); +?> +--EXPECTF-- +array(1) { + [1]=> + string(4) "str%c" +} +array(1) { + [1]=> + string(5) "str%c%c" +} + +Warning: unpack(): Type a: not enough input, need 6, have 5 in %s on line %d +bool(false) +array(1) { + [1]=> + string(5) "str%c%c" +} + diff --git a/ext/standard/tests/strings/bug63874.phpt b/ext/standard/tests/strings/bug63874.phpt new file mode 100644 index 0000000000..066cc155df --- /dev/null +++ b/ext/standard/tests/strings/bug63874.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #63874 (Segfault if php_strip_whitespace has heredoc) +--FILE-- +<?php +echo php_strip_whitespace(__FILE__); + +return <<<A +a +A; +?> +--EXPECT-- +<?php +echo php_strip_whitespace(__FILE__); return <<<A +a +A; +?> diff --git a/ext/standard/tests/strings/implode1.phpt b/ext/standard/tests/strings/implode1.phpt Binary files differindex 3997c54b59..3720c06927 100644 --- a/ext/standard/tests/strings/implode1.phpt +++ b/ext/standard/tests/strings/implode1.phpt diff --git a/ext/standard/tests/strings/pack_A.phpt b/ext/standard/tests/strings/pack_A.phpt new file mode 100644 index 0000000000..59fc22e122 --- /dev/null +++ b/ext/standard/tests/strings/pack_A.phpt @@ -0,0 +1,25 @@ +--TEST-- +pack()/unpack(): "A" modifier +--FILE-- +<?php +var_dump( + pack("A5", "foo "), + pack("A4", "fooo"), + pack("A4", "foo"), + unpack("A*", "foo\0\rbar\0 \t\r\n"), + unpack("A4", "foo\0\rbar\0 \t\r\n") +); +?> +--EXPECTF-- +string(5) "foo " +string(4) "fooo" +string(4) "foo " +array(1) { + [1]=> + string(8) "foo%c%cbar" +} +array(1) { + [1]=> + string(3) "foo" +} + diff --git a/ext/standard/tests/strings/pack_Z.phpt b/ext/standard/tests/strings/pack_Z.phpt new file mode 100644 index 0000000000..4fd007ae0f --- /dev/null +++ b/ext/standard/tests/strings/pack_Z.phpt @@ -0,0 +1,50 @@ +--TEST-- +pack()/unpack(): "Z" format +--FILE-- +<?php +var_dump( + pack("Z0", "f"), + pack("Z5", "foo\0"), + pack("Z4", "fooo"), + pack("Z4", "foo"), + pack("Z*", "foo"), + unpack("Z*", "foo\0\rbar\0 \t\r\n"), + unpack("Z9", "foo\0\rbar\0 \t\r\n"), + unpack("Z2", "\0"), + unpack("Z2", "\0\0"), + unpack("Z2", "A\0"), + unpack("Z2", "AB\0"), + unpack("Z2", "ABC") +); +--EXPECTF-- +Warning: unpack(): Type Z: not enough input, need 2, have 1 in %s on line %d +string(0) "" +string(5) "foo%c%c" +string(4) "foo%c" +string(4) "foo%c" +string(4) "foo%c" +array(1) { + [1]=> + string(3) "foo" +} +array(1) { + [1]=> + string(3) "foo" +} +bool(false) +array(1) { + [1]=> + string(0) "" +} +array(1) { + [1]=> + string(1) "A" +} +array(1) { + [1]=> + string(2) "AB" +} +array(1) { + [1]=> + string(2) "AB" +} diff --git a/ext/standard/tests/strings/parse_str_basic3.phpt b/ext/standard/tests/strings/parse_str_basic3.phpt Binary files differindex 619b1476ab..84f6a53bb1 100644 --- a/ext/standard/tests/strings/parse_str_basic3.phpt +++ b/ext/standard/tests/strings/parse_str_basic3.phpt diff --git a/ext/standard/tests/strings/unpack_error.phpt b/ext/standard/tests/strings/unpack_error.phpt index 43b2df1c0a..1ef97ccbaf 100644 --- a/ext/standard/tests/strings/unpack_error.phpt +++ b/ext/standard/tests/strings/unpack_error.phpt @@ -19,7 +19,7 @@ var_dump(unpack("I", pack("I", 65534), $extra_arg)); echo "\n-- Testing unpack() function with invalid format character --\n"; $extra_arg = 10; -var_dump(unpack("Z", pack("I", 65534))); +var_dump(unpack("G", pack("I", 65534))); ?> ===DONE=== --EXPECTF-- @@ -37,6 +37,6 @@ NULL -- Testing unpack() function with invalid format character -- -Warning: unpack(): Invalid format type Z in %s on line %d +Warning: unpack(): Invalid format type G in %s on line %d bool(false) ===DONE=== diff --git a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt index 226f17572b..0475d12e69 100644 --- a/ext/standard/tests/strings/vprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vprintf_variation15_64bit.phpt @@ -62,8 +62,8 @@ int(16) int(24) -- Iteration 3 -- - 1234000 0 120 -int(25) + 1234000 3875820019684212736 120 +int(34) -- Iteration 4 -- #1 0 $0 10 diff --git a/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt b/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt index 3af1738e56..af55ce966f 100644 --- a/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt +++ b/ext/standard/tests/strings/vsprintf_variation15_64bit.phpt @@ -58,7 +58,7 @@ string(16) "1234567 342391 0" string(24) "12345678900 u 1234 12345" -- Iteration 3 -- -string(25) " 1234000 0 120" +string(34) " 1234000 3875820019684212736 120" -- Iteration 4 -- string(10) "#1 0 $0 10" diff --git a/ext/standard/tests/time/strptime_basic.phpt b/ext/standard/tests/time/strptime_basic.phpt index 194a78f82b..30e3e82cc7 100644 --- a/ext/standard/tests/time/strptime_basic.phpt +++ b/ext/standard/tests/time/strptime_basic.phpt @@ -24,7 +24,7 @@ $input = "10:00:00 AM July 2 1963"; $tstamp = strtotime($input); $str = strftime("%r %B%e %Y %Z", $tstamp); -var_dump(strptime($str, '%H:%M:%S %p %B %d %Y %Z')); +var_dump(strptime($str, '%H:%M:%S %p %B %d %Y')); $str = strftime("%T %D", $tstamp); var_dump(strptime($str, '%H:%M:%S %m/%d/%y')); @@ -55,7 +55,7 @@ array(9) { ["tm_yday"]=> int(182) ["unparsed"]=> - string(3) "GMT" + string(4) " GMT" } array(9) { ["tm_sec"]=> diff --git a/ext/standard/tests/zend_logo_guid.phpt b/ext/standard/tests/zend_logo_guid.phpt deleted file mode 100644 index 44e213b25d..0000000000 --- a/ext/standard/tests/zend_logo_guid.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Checking the zend_logo_guid() function ---CREDITS-- -Sebastian Schürmann -sschuermann@chip.de -Testfest 2009 Munich ---FILE-- -<?php -echo zend_logo_guid(); -?> ---EXPECT-- -PHPE9568F35-D428-11d2-A769-00AA001ACF42 |
