diff options
Diffstat (limited to 'ext/standard/tests')
31 files changed, 1372 insertions, 122 deletions
diff --git a/ext/standard/tests/array/count_invalid.phpt b/ext/standard/tests/array/count_invalid.phpt new file mode 100644 index 0000000000..95da00dac5 --- /dev/null +++ b/ext/standard/tests/array/count_invalid.phpt @@ -0,0 +1,42 @@ +--TEST-- +Only arrays and countable objects can be counted +--FILE-- +<?php + +$result = count(null); +var_dump($result); + +$result = count("string"); +var_dump($result); + +$result = count(123); +var_dump($result); + +$result = count(true); +var_dump($result); + +$result = count(false); +var_dump($result); + +$result = count((object) []); +var_dump($result); + +?> +--EXPECTF-- +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) diff --git a/ext/standard/tests/array/count_recursive.phpt b/ext/standard/tests/array/count_recursive.phpt index 16c754e54f..5c75a0bc68 100644 --- a/ext/standard/tests/array/count_recursive.phpt +++ b/ext/standard/tests/array/count_recursive.phpt @@ -132,7 +132,11 @@ closedir( $resource2 ); --EXPECTF-- *** Testing basic functionality of count() function *** -- Testing NULL -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 0, is 0 + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_RECURSIVE: should be 0, is 0 -- Testing arrays -- COUNT_NORMAL: should be 2, is 2 @@ -141,9 +145,15 @@ COUNT_RECURSIVE: should be 8, is 8 COUNT_NORMAL: should be 3, is 3 COUNT_RECURSIVE: should be 6, is 6 -- Testing strings -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 1, is 1 + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_RECURSIVE: should be 1, is 1 -- Testing various types with no second argument -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 1, is 1 COUNT_NORMAL: should be 2, is 2 -- Testing really cool arrays -- @@ -184,11 +194,19 @@ COUNT_NORMAL is 4 COUNT_RECURSIVE is 7 -- Testing count() on constants with no second argument -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 1, is 1 + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 1, is 1 -- Testing count() on NULL and Unset variables -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 0, is 0 + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d COUNT_NORMAL: should be 1, is 1 COUNT_NORMAL: should be 0, is 0 diff --git a/ext/standard/tests/array/count_variation1.phpt b/ext/standard/tests/array/count_variation1.phpt index b40a2ab299..a58473c219 100644 --- a/ext/standard/tests/array/count_variation1.phpt +++ b/ext/standard/tests/array/count_variation1.phpt @@ -97,74 +97,122 @@ echo "Done"; *** Testing count() : usage variations *** -- Iteration 1 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 2 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 3 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 4 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 5 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 6 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 7 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 8 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 9 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 10 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 11 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 12 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 13 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 14 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 15 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 16 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 17 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 18 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 19 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 20 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 21 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) -- Iteration 22 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 23 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 24 -- + +Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d int(1) Done
\ No newline at end of file diff --git a/ext/standard/tests/array/sizeof_basic1.phpt b/ext/standard/tests/array/sizeof_basic1.phpt index dea4a68ea8..ac86cbf8d7 100644 --- a/ext/standard/tests/array/sizeof_basic1.phpt +++ b/ext/standard/tests/array/sizeof_basic1.phpt @@ -45,16 +45,28 @@ echo "Done"; --EXPECTF-- *** Testing sizeof() : basic functionality *** -- Testing sizeof() for integer type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- -default mode: int(1) +default mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL mode: int(1) +COUNT_NORMAL mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE mode: int(1) +COUNT_RECURSIVE mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Testing sizeof() for float type in default, COUNT_NORMAL and COUNT_RECURSIVE modes -- -default mode: int(1) +default mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL mode: int(1) +COUNT_NORMAL mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE mode: int(1) +COUNT_RECURSIVE mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) Done diff --git a/ext/standard/tests/array/sizeof_object2.phpt b/ext/standard/tests/array/sizeof_object2.phpt index e2c0816c66..404443ae59 100644 --- a/ext/standard/tests/array/sizeof_object2.phpt +++ b/ext/standard/tests/array/sizeof_object2.phpt @@ -101,38 +101,68 @@ echo "Done"; *** Testing sizeof() : object functionality *** --- Testing sizeof() with objects which doesn't implement Countable interface --- -- Iteration 1 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 2 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 3 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 4 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 5 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) Done diff --git a/ext/standard/tests/array/sizeof_variation1.phpt b/ext/standard/tests/array/sizeof_variation1.phpt index 328645f9e2..5917a798e1 100644 --- a/ext/standard/tests/array/sizeof_variation1.phpt +++ b/ext/standard/tests/array/sizeof_variation1.phpt @@ -66,150 +66,264 @@ for($i = 0; $i < count($values); $i++) echo "COUNT_NORMAL Mode: "; var_dump( sizeof($var, COUNT_NORMAL) ); echo "\n"; - + echo "COUNT_RECURSIVE Mode: "; var_dump( sizeof($var, COUNT_RECURSIVE) ); echo "\n"; - + $counter++; } - + echo "Done"; ?> --EXPECTF-- *** Testing sizeof() : usage variations *** --- Testing sizeof() for all scalar types in default,COUNT_NORMAL and COUNT_RECURSIVE mode --- -- Iteration 1 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 2 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 3 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 4 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 5 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 6 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 7 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 8 -- -Default Mode: int(0) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -COUNT_NORMAL Mode: int(0) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -COUNT_RECURSIVE Mode: int(0) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -- Iteration 9 -- -Default Mode: int(0) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -COUNT_NORMAL Mode: int(0) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -COUNT_RECURSIVE Mode: int(0) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -- Iteration 10 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 11 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 12 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 13 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 14 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 15 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 16 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 17 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -- Iteration 18 -- -Default Mode: int(0) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -COUNT_NORMAL Mode: int(0) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -COUNT_RECURSIVE Mode: int(0) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(0) -- Iteration 19 -- -Default Mode: int(1) +Default Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_NORMAL Mode: int(1) +COUNT_NORMAL Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) -COUNT_RECURSIVE Mode: int(1) +COUNT_RECURSIVE Mode: +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d +int(1) Done diff --git a/ext/standard/tests/array/sizeof_variation4.phpt b/ext/standard/tests/array/sizeof_variation4.phpt index cb8fecc822..63fc05bd46 100644 --- a/ext/standard/tests/array/sizeof_variation4.phpt +++ b/ext/standard/tests/array/sizeof_variation4.phpt @@ -90,261 +90,381 @@ echo "Done"; -- Iteration 1 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 2 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 3 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 4 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 5 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 6 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 7 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 8 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 9 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 10 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 11 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 12 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 13 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 14 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 15 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 16 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 17 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 18 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 19 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) -- Iteration 20 -- Default Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_NORMAL Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) COUNT_RECURSIVE Mode: Notice: Undefined variable: value in %s on line %d + +Warning: sizeof(): Parameter must be an array or an object that implements Countable in %s on line %d int(0) Done diff --git a/ext/standard/tests/array/var_export.phpt b/ext/standard/tests/array/var_export.phpt index 8caf40789f..0b1f76094d 100644 --- a/ext/standard/tests/array/var_export.phpt +++ b/ext/standard/tests/array/var_export.phpt @@ -7,7 +7,7 @@ var_export($a); ?> --EXPECT-- stdClass::__set_state(array( - 0 => 1, - 1 => 3, + '0' => 1, + '1' => 3, 'foo' => 'bar', )) diff --git a/ext/standard/tests/class_object/get_class_variation_001.phpt b/ext/standard/tests/class_object/get_class_variation_001.phpt index d39da3a991..3987968e90 100644 --- a/ext/standard/tests/class_object/get_class_variation_001.phpt +++ b/ext/standard/tests/class_object/get_class_variation_001.phpt @@ -152,12 +152,12 @@ bool(false) Arg value: (type: NULL) -Warning: get_class() called without object from outside a class in %sget_class_variation_001.php on line %d +Warning: get_class() expects parameter 1 to be object, null given in %s on line %d bool(false) Arg value: (type: NULL) -Warning: get_class() called without object from outside a class in %sget_class_variation_001.php on line %d +Warning: get_class() expects parameter 1 to be object, null given in %s on line %d bool(false) Arg value: 1 (type: boolean) @@ -202,11 +202,11 @@ bool(false) Arg value: (type: NULL) -Warning: get_class() called without object from outside a class in %sget_class_variation_001.php on line %d +Warning: get_class() expects parameter 1 to be object, null given in %s on line %d bool(false) Arg value: (type: NULL) -Warning: get_class() called without object from outside a class in %sget_class_variation_001.php on line %d +Warning: get_class() expects parameter 1 to be object, null given in %s on line %d bool(false) Done diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt index c7a72de944..f743e7456c 100644 --- a/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt +++ b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt @@ -5,8 +5,6 @@ Francesco Fullone ff@ideato.it #PHPTestFest Cesena Italia on 2009-06-20 --INI-- magic_quotes_gpc=1 ---SKIPIF-- -<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or greater"); ?> --FILE-- <?php echo "*** Test by calling method or function with deprecated option ***\n"; diff --git a/ext/standard/tests/general_functions/gettype_settype_basic.phpt b/ext/standard/tests/general_functions/gettype_settype_basic.phpt index b2762fd83a..b082fbf5f5 100644 --- a/ext/standard/tests/general_functions/gettype_settype_basic.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_basic.phpt @@ -740,11 +740,11 @@ string(5) "array" -- Iteration 1 -- bool(true) object(stdClass)#2 (3) { - [0]=> + ["0"]=> int(1) - [1]=> + ["1"]=> int(2) - [2]=> + ["2"]=> int(3) } string(6) "object" @@ -758,11 +758,11 @@ string(6) "object" -- Iteration 3 -- bool(true) object(stdClass)#2 (3) { - [0]=> + ["0"]=> int(2) - [1]=> + ["1"]=> int(3) - [2]=> + ["2"]=> int(4) } string(6) "object" diff --git a/ext/standard/tests/general_functions/gettype_settype_variation7.phpt b/ext/standard/tests/general_functions/gettype_settype_variation7.phpt index 437a966fd1..c4246b4204 100644 --- a/ext/standard/tests/general_functions/gettype_settype_variation7.phpt +++ b/ext/standard/tests/general_functions/gettype_settype_variation7.phpt @@ -531,7 +531,7 @@ string(6) "object" string(5) "array" bool(true) object(stdClass)#4 (1) { - [0]=> + ["0"]=> NULL } string(6) "object" @@ -539,13 +539,13 @@ string(6) "object" string(5) "array" bool(true) object(stdClass)#4 (4) { - [0]=> + ["0"]=> int(1) - [1]=> + ["1"]=> int(2) - [2]=> + ["2"]=> int(3) - [3]=> + ["3"]=> int(4) } string(6) "object" @@ -553,11 +553,11 @@ string(6) "object" string(5) "array" bool(true) object(stdClass)#4 (4) { - [1]=> + ["1"]=> string(3) "one" - [2]=> + ["2"]=> string(3) "two" - [3]=> + ["3"]=> string(5) "three" ["four"]=> int(4) @@ -567,11 +567,11 @@ string(6) "object" string(5) "array" bool(true) object(stdClass)#4 (3) { - [0]=> + ["0"]=> float(1.5) - [1]=> + ["1"]=> float(2.4) - [2]=> + ["2"]=> float(6500000) } string(6) "object" diff --git a/ext/standard/tests/general_functions/proc_nice_basic-win.phpt b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt new file mode 100644 index 0000000000..157ad74783 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt @@ -0,0 +1,94 @@ +--TEST-- +proc_nice() basic behaviour +--SKIPIF-- +<?php +/* No function_exists() check, proc_nice() is always available on Windows */ + +if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { + die('skip: Only for Windows'); +} + +if (PHP_SAPI != 'cli') { + die('skip: Only for CLI'); +} + +if (getenv('SKIP_SLOW_TESTS')) { + doe('skip: Slow test'); +} +?> +--FILE-- +<?php +function get_priority_from_wmic() { + static $bin, $pid; + + if (!$bin) { + $t = explode('\\', PHP_BINARY); + + $bin = end($t); + $pid = getmypid(); + } + + $t = ''; + $p = popen('wmic process where name="' . $bin . '"', 'r'); + + if (!$p) { + return false; + } + + while(!feof($p)) { + $t .= fread($p, 1024); + } + + pclose($p); + + $t = explode(PHP_EOL, $t); + + $f = false; + $m = [ + strpos($t[0], ' ProcessId' ), + strpos($t[0], ' Priority ') + ]; + + foreach ($t as $n => $l) { + if (!$n || empty($l)) { + continue; + } + + $d = []; + + foreach ($m as $c) { + $d[] = (int) substr($l, $c + 1, strpos($l, ' ', $c + 2) - ($c + 1)); + } + + if ($d[0] === $pid) { + return $d[1]; + } + } + + return false; +} + +$p = [ + /* '<verbose name>' => ['<wmic value>', '<proc_nice value>'] */ + + 'Idle' => [4, 10], + 'Below normal' => [6, 5], + 'Normal' => [8, 0], + 'Above normal' => [10, -5], + 'High priority' => [13, -10] + ]; + +foreach ($p as $test => $data) { + printf('Testing \'%s\' (%d): ', $test, $data[1]); + + proc_nice($data[1]); + + print (($wp = get_priority_from_wmic()) === $data[0] ? 'Passed' : 'Failed (' . $wp . ')') . PHP_EOL; +} +?> +--EXPECTF-- +Testing 'Idle' (10): Passed +Testing 'Below normal' (5): Passed +Testing 'Normal' (0): Passed +Testing 'Above normal' (-5): Passed +Testing 'High priority' (-10): Passed diff --git a/ext/standard/tests/general_functions/proc_nice_basic.phpt b/ext/standard/tests/general_functions/proc_nice_basic.phpt index 83b5165679..12469bf4eb 100644 --- a/ext/standard/tests/general_functions/proc_nice_basic.phpt +++ b/ext/standard/tests/general_functions/proc_nice_basic.phpt @@ -8,6 +8,7 @@ Simone Gentili (sensorario@gmail.com) --SKIPIF-- <?php if(!function_exists('proc_nice')) die("skip. proc_nice not available "); +if(substr(strtoupper(PHP_OS), 0, 3) == 'WIN') die('skip. not for Windows'); ?> --FILE-- <?php diff --git a/ext/standard/tests/general_functions/type.phpt b/ext/standard/tests/general_functions/type.phpt index eb6f0672fe..ac29a1bf38 100644 --- a/ext/standard/tests/general_functions/type.phpt +++ b/ext/standard/tests/general_functions/type.phpt @@ -63,7 +63,7 @@ string(6) "double" string(4) "NULL" string(7) "boolean" string(6) "string" -string(12) "unknown type" +string(17) "resource (closed)" string(8) "resource" string(6) "object" bool(true) @@ -265,11 +265,11 @@ array(0) { } bool(true) object(stdClass)#%d (3) { - [0]=> + ["0"]=> int(1) - [1]=> + ["1"]=> int(2) - [2]=> + ["2"]=> int(3) } bool(true) @@ -279,11 +279,11 @@ object(stdClass)#%d (1) { } bool(true) object(stdClass)#%d (3) { - [0]=> + ["0"]=> int(2) - [1]=> + ["1"]=> int(3) - [2]=> + ["2"]=> int(4) } bool(true) diff --git a/ext/standard/tests/mail/mail_basic7.phpt b/ext/standard/tests/mail/mail_basic7.phpt new file mode 100644 index 0000000000..3b389d2c4e --- /dev/null +++ b/ext/standard/tests/mail/mail_basic7.phpt @@ -0,0 +1,218 @@ +--TEST-- +Test mail() function : array extra header basic functionality +--INI-- +sendmail_path=tee mailBasic.out >/dev/null +mail.add_x_header = Off +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Won't run on Windows"); +?> +--FILE-- +<?php +/* Prototype : int mail(string to, string subject, string message [, mixed additional_headers [, string additional_parameters]]) + * Description: Send an email message + * Source code: ext/standard/mail.c + * Alias to functions: + */ + +error_reporting(-1); + +echo "*** Testing mail() : basic functionality ***\n"; + +echo "\n\n************* TEST ******************\n"; +// Should pass +// Initialise all required variables +$to = 'user@example.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$additional_headers = array( + 'KHeaders' => 'aaaa', + 'bcc'=>'foo@bar', + 'foo'=> + array( + "bar\r\n hoge", + "bar\r\n\t fuga", + ), +); +$outFile = "mailBasic.out"; +@unlink($outFile); + +echo "-- All Mail Content Parameters --\n"; +// Calling mail() with all additional headers +var_dump( mail($to, $subject, $message, $additional_headers) ); +echo file_get_contents($outFile); +unlink($outFile); + + +echo "\n\n************* TEST ******************\n"; +// Should fail all +// Initialise all required variables +$to = 'user@example.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +// Headers should not have array values +$additional_headers = array( + 'orig-date' => array('foo1'), + 'from' => array('foo2'), + 'sender' => array('foo3'), + 'reply-to' => array('foo4'), + 'to' => array('foo5'), + 'bcc' => array('foo6'), + 'message-id' => array('foo7'), + 'in-reply-to'=> array('foo8'), +); +$outFile = "mailBasic.out"; +@unlink($outFile); + +echo "-- All Mail Content Parameters --\n"; +// Calling mail() with all additional headers +var_dump( mail($to, $subject, $message, $additional_headers) ); +echo file_get_contents($outFile); +unlink($outFile); + + +echo "\n\n************* TEST ******************\n"; +// Should fail all +// Initialise all required variables +$to = 'user@example.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$additional_headers = array( + 'foo1' => array('foo1'=>'bar1'), + 'foo2' => array('foo2', array('foo3')), + 'foo3' => array(123), + 'foo4' => array(123.456), + 'foo5' => array(FALSE), + 'foo6' => array(NULL), + 'foo7' => array(new StdClass), +); +$outFile = "mailBasic.out"; +@unlink($outFile); + +echo "-- All Mail Content Parameters --\n"; +// Calling mail() with all additional headers +var_dump( mail($to, $subject, $message, $additional_headers) ); +echo file_get_contents($outFile); +unlink($outFile); + + +echo "\n\n************* TEST ******************\n"; +// Should fail most +// Initialise all required variables +$to = 'user@example.com'; +$subject = 'Test Subject'; +$message = 'A Message'; +$additional_headers = array( + '*:foo1' => array('bar1'), + 'foo2:::' => array('bar1'), + 'foo3()' => array('bar1'), + 'foo4@' => array('bar1'), + 'foo5|' => array('bar1'), + "\0foo6" => array('bar1'), + "foo7\0" => array('bar1'), + "foo8" => array(), + "foo9" => '%&$#!', + "foo10" => "abc\0\tdef", +); +$outFile = "mailBasic.out"; +@unlink($outFile); + +echo "-- All Mail Content Parameters --\n"; +// Calling mail() with all additional headers +var_dump( mail($to, $subject, $message, $additional_headers) ); +echo file_get_contents($outFile); +unlink($outFile); + +?> +===DONE=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + + +************* TEST ****************** +-- All Mail Content Parameters -- +bool(true) +To: user@example.com +Subject: Test Subject +KHeaders: aaaa +bcc: foo@bar +foo: bar + hoge +foo: bar + fuga + +A Message + + +************* TEST ****************** +-- All Mail Content Parameters -- + +Warning: mail(): 'orig-date' header must be at most one header. Array is passed for 'orig-date' in %s on line 59 + +Warning: mail(): 'from' header must be at most one header. Array is passed for 'from' in %s on line 59 + +Warning: mail(): 'sender' header must be at most one header. Array is passed for 'sender' in %s on line 59 + +Warning: mail(): 'reply-to' header must be at most one header. Array is passed for 'reply-to' in %s on line 59 + +Warning: mail(): Extra header cannot contain 'To' header in %s on line 59 + +Warning: mail(): 'bcc' header must be at most one header. Array is passed for 'bcc' in %s on line 59 + +Warning: mail(): 'message-id' header must be at most one header. Array is passed for 'message-id' in %s on line 59 + +Warning: mail(): 'in-reply-to' header must be at most one header. Array is passed for 'in-reply-to' in %s on line 59 +bool(true) +To: user@example.com +Subject: Test Subject + +A Message + + +************* TEST ****************** +-- All Mail Content Parameters -- + +Warning: mail(): Multiple header key must be numeric index (foo1) in %s on line 84 + +Warning: mail(): Multiple header values must be string (foo2) in %s on line 84 + +Warning: mail(): Multiple header values must be string (foo3) in %s on line 84 + +Warning: mail(): Multiple header values must be string (foo4) in %s on line 84 + +Warning: mail(): Multiple header values must be string (foo5) in %s on line 84 + +Warning: mail(): Multiple header values must be string (foo6) in %s on line 84 + +Warning: mail(): Multiple header values must be string (foo7) in %s on line 84 +bool(true) +To: user@example.com +Subject: Test Subject +foo2: foo2 + +A Message + + +************* TEST ****************** +-- All Mail Content Parameters -- + +Warning: mail(): Header field name (*:foo1) contains invalid chars in %s on line 112 + +Warning: mail(): Header field name (foo2:::) contains invalid chars in %s on line 112 + +Warning: mail(): Header field name () contains invalid chars in %s on line 112 + +Warning: mail(): Header field name (foo7) contains invalid chars in %s on line 112 + +Warning: mail(): Header field value (foo10 => abc) contains invalid chars or format in %s on line 112 +bool(true) +To: user@example.com +Subject: Test Subject +foo3(): bar1 +foo4@: bar1 +foo5|: bar1 +foo9: %&$#! + +A Message +===DONE=== diff --git a/ext/standard/tests/network/dns_get_mx.phpt b/ext/standard/tests/network/dns_get_mx.phpt index c5bf361b12..f6bb7ec05e 100644 --- a/ext/standard/tests/network/dns_get_mx.phpt +++ b/ext/standard/tests/network/dns_get_mx.phpt @@ -14,7 +14,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { ?> --FILE-- <?php -$domains = array('yahoo.co.jp', 'yahoo.com', 'es.yahoo.com', 'fr.yahoo.com', 'it.yahoo.com'); +$domains = array('php.net', 'doc.php.net', 'wiki.php.net'); foreach ($domains as $domain) { if (getmxrr($domain, $hosts, $weights)) { echo "Hosts: " . count($hosts) . ", weights: " . count($weights) . "\n"; @@ -25,5 +25,3 @@ foreach ($domains as $domain) { Hosts: %i, weights: %i Hosts: %i, weights: %i Hosts: %i, weights: %i -Hosts: %i, weights: %i -Hosts: %i, weights: %i diff --git a/ext/standard/tests/password/password_get_info_argon2.phpt b/ext/standard/tests/password/password_get_info_argon2.phpt new file mode 100644 index 0000000000..80c6f93416 --- /dev/null +++ b/ext/standard/tests/password/password_get_info_argon2.phpt @@ -0,0 +1,29 @@ +--TEST--
+Test normal operation of password_get_info() with Argon2
+--SKIPIF--
+<?php
+if (!defined('PASSWORD_ARGON2I')) die('skip password_get_info not built with Argon2');
+?>
+--FILE--
+<?php
+
+var_dump(password_get_info('$argon2i$v=19$m=65536,t=3,p=1$SWhIcG5MT21Pc01PbWdVZw$WagZELICsz7jlqOR2YzoEVTWb2oOX1tYdnhZYXxptbU'));
+echo "OK!";
+?>
+--EXPECT--
+array(3) {
+ ["algo"]=>
+ int(2)
+ ["algoName"]=>
+ string(7) "argon2i"
+ ["options"]=>
+ array(3) {
+ ["memory_cost"]=>
+ int(65536)
+ ["time_cost"]=>
+ int(3)
+ ["threads"]=>
+ int(1)
+ }
+}
+OK!
\ No newline at end of file diff --git a/ext/standard/tests/password/password_hash_argon2.phpt b/ext/standard/tests/password/password_hash_argon2.phpt new file mode 100644 index 0000000000..7bd8cd700c --- /dev/null +++ b/ext/standard/tests/password/password_hash_argon2.phpt @@ -0,0 +1,18 @@ +--TEST--
+Test normal operation of password_hash() with argon2
+--SKIPIF--
+<?php
+if (!defined('PASSWORD_ARGON2I')) die('skip password_hash not built with Argon2');
+--FILE--
+<?php
+
+$password = "the password for testing 12345!";
+
+$hash = password_hash($password, PASSWORD_ARGON2I);
+var_dump(password_verify($password, $hash));
+
+echo "OK!";
+?>
+--EXPECT--
+bool(true)
+OK!
\ No newline at end of file diff --git a/ext/standard/tests/password/password_hash_error_argon2.phpt b/ext/standard/tests/password/password_hash_error_argon2.phpt new file mode 100644 index 0000000000..7e8722ec6f --- /dev/null +++ b/ext/standard/tests/password/password_hash_error_argon2.phpt @@ -0,0 +1,21 @@ +--TEST--
+Test error operation of password_hash() with argon2
+--SKIPIF--
+<?php
+if (!defined('PASSWORD_ARGON2I')) die('skip password_hash not built with Argon2');
+?>
+--FILE--
+<?php
+var_dump(password_hash('test', PASSWORD_ARGON2I, ['memory_cost' => 0]));
+var_dump(password_hash('test', PASSWORD_ARGON2I, ['time_cost' => 0]));
+var_dump(password_hash('test', PASSWORD_ARGON2I, ['threads' => 0]));
+?>
+--EXPECTF--
+Warning: password_hash(): Memory cost is outside of allowed memory range in %s on line %d
+NULL
+
+Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d
+NULL
+
+Warning: password_hash(): Invalid number of threads in %s on line %d
+NULL
\ No newline at end of file diff --git a/ext/standard/tests/password/password_needs_rehash_argon2.phpt b/ext/standard/tests/password/password_needs_rehash_argon2.phpt new file mode 100644 index 0000000000..61fc0a5cae --- /dev/null +++ b/ext/standard/tests/password/password_needs_rehash_argon2.phpt @@ -0,0 +1,22 @@ +--TEST--
+Test normal operation of password_needs_rehash() with argon2
+--SKIPIF--
+<?php
+if (!defined('PASSWORD_ARGON2I')) die('skip password_needs_rehash not built with Argon2');
+?>
+--FILE--
+<?php
+
+$hash = password_hash('test', PASSWORD_ARGON2I);
+var_dump(password_needs_rehash($hash, PASSWORD_ARGON2I));
+var_dump(password_needs_rehash($hash, PASSWORD_ARGON2I, ['memory_cost' => 1<<17]));
+var_dump(password_needs_rehash($hash, PASSWORD_ARGON2I, ['time_cost' => 4]));
+var_dump(password_needs_rehash($hash, PASSWORD_ARGON2I, ['threads' => 4]));
+echo "OK!";
+?>
+--EXPECT--
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+OK!
diff --git a/ext/standard/tests/password/password_verify_argon2.phpt b/ext/standard/tests/password/password_verify_argon2.phpt new file mode 100644 index 0000000000..e3a35942f5 --- /dev/null +++ b/ext/standard/tests/password/password_verify_argon2.phpt @@ -0,0 +1,18 @@ +--TEST--
+Test normal operation of password_verify() with argon2
+--SKIPIF--
+<?php
+if (!defined('PASSWORD_ARGON2I')) die('skip password_verify not built with Argon2');
+?>
+--FILE--
+<?php
+
+var_dump(password_verify('test', '$argon2i$v=19$m=65536,t=3,p=1$OEVjWWs2Z3YvWlNZQ0ZmNw$JKin7ahjmh8JYvMyFcXri0Ss/Uvd3uYpD7MG6C/5Cy0'));
+
+var_dump(password_verify('argon2', '$argon2i$v=19$m=65536,t=3,p=1$OEVjWWs2Z3YvWlNZQ0ZmNw$JKin7ahjmh8JYvMyFcXri0Ss/Uvd3uYpD7MG6C/5Cy0'));
+echo "OK!";
+?>
+--EXPECT--
+bool(true)
+bool(false)
+OK!
\ No newline at end of file diff --git a/ext/standard/tests/serialize/serialization_objects_005.phpt b/ext/standard/tests/serialize/serialization_objects_005.phpt index 35b1593879..9800168ca2 100644 --- a/ext/standard/tests/serialize/serialization_objects_005.phpt +++ b/ext/standard/tests/serialize/serialization_objects_005.phpt @@ -88,7 +88,7 @@ object(__PHP_Incomplete_Class)#%d (2) { ["p"]=> int(1) } -bool(false) +bool(true) Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 43 NULL @@ -117,4 +117,4 @@ Notice: main(): The script tried to execute a method or access a property of an Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 57 NULL -Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 59
\ No newline at end of file +Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line 59 diff --git a/ext/standard/tests/strings/bug43957.phpt b/ext/standard/tests/strings/bug43957.phpt new file mode 100644 index 0000000000..0380787b73 --- /dev/null +++ b/ext/standard/tests/strings/bug43957.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #43957 (utf8_decode() bogus conversion on multibyte indicator near end of string) +--FILE-- +<?php + echo utf8_decode('abc'.chr(0xe0)); +?> +--EXPECTF-- +abc? diff --git a/ext/standard/tests/strings/bug49687.phpt b/ext/standard/tests/strings/bug49687.phpt new file mode 100644 index 0000000000..99e8dc3ec6 --- /dev/null +++ b/ext/standard/tests/strings/bug49687.phpt @@ -0,0 +1,19 @@ +--TEST--
+Bug #49687 Several utf8_decode deficiencies and vulnerabilities
+--FILE--
+<?php
+
+$tests = array(
+ "\x41\xC2\x3E\x42",
+ "\xE3\x80\x22",
+ "\x41\x98\xBA\x42\xE2\x98\x43\xE2\x98\xBA\xE2\x98",
+);
+foreach ($tests as $t) {
+ echo bin2hex(utf8_decode($t)), "\n";
+}
+echo "Done.\n";
+--EXPECT--
+413f3e42
+3f22
+413f3f423f433f3f
+Done.
diff --git a/ext/standard/tests/strings/http_build_query_variation3.phpt b/ext/standard/tests/strings/http_build_query_variation3.phpt index 107120e084..350f3c8661 100644 --- a/ext/standard/tests/strings/http_build_query_variation3.phpt +++ b/ext/standard/tests/strings/http_build_query_variation3.phpt @@ -2,10 +2,6 @@ Test http_build_query() function: usage variations - testing four parameter added in PHP 5.4.0 --CREDITS-- Adam Gegotek <adam [dot] gegotek [at] gmail [dot] com> ---SKIPIF-- -<?php - if (version_compare(PHP_VERSION, '5.4.0', '<')) die("skip this test if PHP_VERSION is less than 5.4.0"); -?> --FILE-- <?php /* Prototype : string http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] ) diff --git a/ext/standard/tests/strings/utf8.phpt b/ext/standard/tests/strings/utf8.phpt new file mode 100644 index 0000000000..aea04fdecd --- /dev/null +++ b/ext/standard/tests/strings/utf8.phpt @@ -0,0 +1,10 @@ +--TEST-- +UTF-8<->ISO Latin 1 encoding/decoding test +--FILE-- +<?php +printf("%s -> %s\n", urlencode("æ"), urlencode(utf8_encode("æ"))); +printf("%s <- %s\n", urlencode(utf8_decode(urldecode("%C3%A6"))), "%C3%A6"); +?> +--EXPECT-- +%E6 -> %C3%A6 +%E6 <- %C3%A6 diff --git a/ext/standard/tests/strings/utf8_decode_error.phpt b/ext/standard/tests/strings/utf8_decode_error.phpt new file mode 100644 index 0000000000..911cc15cfc --- /dev/null +++ b/ext/standard/tests/strings/utf8_decode_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test utf8_decode() function : error conditions +--FILE-- +<?php +/* Prototype : proto string utf8_decode(string data) + * Description: Converts a UTF-8 encoded string to ISO-8859-1 + * Source code: ext/standard/string.c + * Alias to functions: + */ + +echo "*** Testing utf8_decode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing utf8_decode() function with Zero arguments --\n"; +var_dump( utf8_decode() ); + +//Test utf8_decode with one more than the expected number of arguments +echo "\n-- Testing utf8_decode() function with more than expected no. of arguments --\n"; +$data = 'string_val'; +$extra_arg = 10; +var_dump( utf8_decode($data, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_decode() : error conditions *** + +-- Testing utf8_decode() function with Zero arguments -- + +Warning: utf8_decode() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing utf8_decode() function with more than expected no. of arguments -- + +Warning: utf8_decode() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/standard/tests/strings/utf8_decode_variation1.phpt b/ext/standard/tests/strings/utf8_decode_variation1.phpt new file mode 100644 index 0000000000..f564b87da0 --- /dev/null +++ b/ext/standard/tests/strings/utf8_decode_variation1.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test utf8_decode() function : usage variations - different types for data +--FILE-- +<?php +/* Prototype : proto string utf8_decode(string data) + * Description: Converts a UTF-8 encoded string to ISO-8859-1 + * Source code: ext/standard/string.c + * Alias to functions: + */ + +echo "*** Testing utf8_decode() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new aClass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for data + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( utf8_decode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_decode() : usage variations *** + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value Some Ascii Data +string(15) "Some Ascii Data" + +Arg value +string(0) "" + +Arg value +string(0) "" +Done + diff --git a/ext/standard/tests/strings/utf8_encode_error.phpt b/ext/standard/tests/strings/utf8_encode_error.phpt new file mode 100644 index 0000000000..e12f0978b6 --- /dev/null +++ b/ext/standard/tests/strings/utf8_encode_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test utf8_encode() function : error conditions +--FILE-- +<?php +/* Prototype : proto string utf8_encode(string data) + * Description: Encodes an ISO-8859-1 string to UTF-8 + * Source code: ext/standard/string.c + * Alias to functions: + */ + +echo "*** Testing utf8_encode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing utf8_encode() function with Zero arguments --\n"; +var_dump( utf8_encode() ); + +//Test utf8_encode with one more than the expected number of arguments +echo "\n-- Testing utf8_encode() function with more than expected no. of arguments --\n"; +$data = 'string_val'; +$extra_arg = 10; +var_dump( utf8_encode($data, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_encode() : error conditions *** + +-- Testing utf8_encode() function with Zero arguments -- + +Warning: utf8_encode() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing utf8_encode() function with more than expected no. of arguments -- + +Warning: utf8_encode() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done + diff --git a/ext/standard/tests/strings/utf8_encode_variation1.phpt b/ext/standard/tests/strings/utf8_encode_variation1.phpt new file mode 100644 index 0000000000..fa4b79976e --- /dev/null +++ b/ext/standard/tests/strings/utf8_encode_variation1.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test utf8_encode() function : usage variations - <type here specifics of this variation> +--FILE-- +<?php +/* Prototype : proto string utf8_encode(string data) + * Description: Encodes an ISO-8859-1 string to UTF-8 + * Source code: ext/standard/string.c + * Alias to functions: + */ + +echo "*** Testing utf8_encode() : usage variations ***\n"; +error_reporting(E_ALL & ~E_NOTICE); + +class aClass { + function __toString() { + return "Some Ascii Data"; + } +} + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new aClass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for data + +foreach($values as $value) { + echo @"\nArg value $value \n"; + var_dump( utf8_encode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing utf8_encode() : usage variations *** + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value Array + +Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value Some Ascii Data +string(15) "Some Ascii Data" + +Arg value +string(0) "" + +Arg value +string(0) "" +Done + |