From d1acb8d4ebd5b7bf2b7ec2e1f2a4b79a6f038f02 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Wed, 15 Nov 2006 22:44:29 +0000 Subject: add new tests, improve existing ones --- ext/standard/tests/array/array_flip.phpt | 21 +++++++++ ext/standard/tests/array/array_key_exists.phpt | 40 +++++++++++++++++ ext/standard/tests/array/array_pad.phpt | 4 ++ ext/standard/tests/array/array_rand.phpt | 51 ++++++++++++++++++++++ ext/standard/tests/array/array_unshift.phpt | 40 +++++++++++++++++ ext/standard/tests/array/array_values.phpt | 47 ++++++++++++++++++++ ext/standard/tests/array/compact.phpt | 60 ++++++++++++++++++++++++++ ext/standard/tests/file/statpage.phpt | 20 +++++++++ 8 files changed, 283 insertions(+) create mode 100644 ext/standard/tests/array/array_key_exists.phpt create mode 100644 ext/standard/tests/array/array_rand.phpt create mode 100644 ext/standard/tests/array/array_unshift.phpt create mode 100644 ext/standard/tests/array/array_values.phpt create mode 100644 ext/standard/tests/array/compact.phpt create mode 100644 ext/standard/tests/file/statpage.phpt (limited to 'ext') diff --git a/ext/standard/tests/array/array_flip.phpt b/ext/standard/tests/array/array_flip.phpt index c268f5aaf6..8d8622cd11 100644 --- a/ext/standard/tests/array/array_flip.phpt +++ b/ext/standard/tests/array/array_flip.phpt @@ -14,6 +14,13 @@ $trans = array("a" => 1, 2 => "i"); $trans = array_flip($trans); var_dump($trans); + +var_dump(array_flip()); +var_dump(array_flip(array())); +var_dump(array_flip(array(1))); +var_dump(array_flip(array(array()))); + +echo "Done\n"; ?> --EXPECTF-- Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d @@ -35,3 +42,17 @@ array(6) { ["i"]=> int(2) } + +Warning: Wrong parameter count for array_flip() in %s on line %d +NULL +array(0) { +} +array(1) { + [1]=> + int(0) +} + +Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d +array(0) { +} +Done diff --git a/ext/standard/tests/array/array_key_exists.phpt b/ext/standard/tests/array/array_key_exists.phpt new file mode 100644 index 0000000000..e7b6c06773 --- /dev/null +++ b/ext/standard/tests/array/array_key_exists.phpt @@ -0,0 +1,40 @@ +--TEST-- +array_key_exists() tests +--FILE-- +1))); +var_dump(array_key_exists("a", array(3,2,1))); +var_dump(array_key_exists(NULL, array(5,6,7,""=>"value", 3,2,1))); +var_dump(array_key_exists(NULL, array(5,6,7,3,2,1))); +var_dump(array_key_exists(false, array(5,6,7,""=>"value", 3,2,1))); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for array_key_exists() in %s on line %d +NULL + +Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d +bool(false) + +Warning: array_key_exists(): The second argument should be either an array or an object in %s on line %d +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) + +Warning: array_key_exists(): The first argument should be either a string or an integer in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/array/array_pad.phpt b/ext/standard/tests/array/array_pad.phpt index 96a4503311..e6c4590c16 100644 --- a/ext/standard/tests/array/array_pad.phpt +++ b/ext/standard/tests/array/array_pad.phpt @@ -16,6 +16,7 @@ var_dump(array_pad(array("", -1, 2.0), 2, array())); var_dump(array_pad(array("", -1, 2.0), -3, array())); var_dump(array_pad(array("", -1, 2.0), -4, array())); var_dump(array_pad(array("", -1, 2.0), 2000000, 0)); +var_dump(array_pad("", 2000000, 0)); echo "Done\n"; ?> @@ -94,4 +95,7 @@ array(4) { Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d bool(false) + +Warning: array_pad(): The argument should be an array in %s on line %d +NULL Done diff --git a/ext/standard/tests/array/array_rand.phpt b/ext/standard/tests/array/array_rand.phpt new file mode 100644 index 0000000000..22424465a6 --- /dev/null +++ b/ext/standard/tests/array/array_rand.phpt @@ -0,0 +1,51 @@ +--TEST-- +array_rand() tests +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for array_rand() in %s on line %d +NULL +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL + +Warning: array_rand(): First argument has to be an array in %s on line %d +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL + +Warning: array_rand(): Second argument has to be between 1 and the number of elements in the array in %s on line %d +NULL +array(3) { + [0]=> + int(%d) + [1]=> + int(%d) + [2]=> + int(%d) +} +array(2) { + [0]=> + int(%d) + [1]=> + int(%d) +} +Done diff --git a/ext/standard/tests/array/array_unshift.phpt b/ext/standard/tests/array/array_unshift.phpt new file mode 100644 index 0000000000..0e8dae9196 --- /dev/null +++ b/ext/standard/tests/array/array_unshift.phpt @@ -0,0 +1,40 @@ +--TEST-- +array_unshift() tests +--FILE-- + +--EXPECTF-- +int(1) +array(1) { + [0]=> + string(0) "" +} + +Warning: array_unshift(): The first argument should be an array in %s on line %d +bool(false) +array(1) { + [0]=> + string(0) "" +} +int(2) +array(2) { + [0]=> + array(1) { + [0]=> + string(0) "" + } + [1]=> + string(0) "" +} +Done diff --git a/ext/standard/tests/array/array_values.phpt b/ext/standard/tests/array/array_values.phpt new file mode 100644 index 0000000000..42e252ac81 --- /dev/null +++ b/ext/standard/tests/array/array_values.phpt @@ -0,0 +1,47 @@ +--TEST-- +array_values() tests +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for array_values() in %s on line %d +NULL +array(0) { +} + +Warning: array_values(): The argument should be an array in %s on line %d +NULL + +Warning: array_values(): The argument should be an array in %s on line %d +NULL +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + float(2) + [3]=> + string(6) "asdasd" + [4]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +Done diff --git a/ext/standard/tests/array/compact.phpt b/ext/standard/tests/array/compact.phpt new file mode 100644 index 0000000000..b70e558460 --- /dev/null +++ b/ext/standard/tests/array/compact.phpt @@ -0,0 +1,60 @@ +--TEST-- +compact() tests +--FILE-- + +--EXPECTF-- +array(3) { + ["var1"]=> + string(4) "test" + ["var2"]=> + string(8) "one more" + ["var3"]=> + string(16) "and the last one" +} +array(0) { +} +array(0) { +} +array(0) { +} +array(1) { + ["_"]=> + string(1) "a" +} +array(1) { + ["var3"]=> + string(16) "and the last one" +} +array(2) { + ["var2"]=> + string(8) "one more" + ["var3"]=> + string(16) "and the last one" +} +array(1) { + ["var1"]=> + string(4) "test" +} +array(0) { +} +Done diff --git a/ext/standard/tests/file/statpage.phpt b/ext/standard/tests/file/statpage.phpt new file mode 100644 index 0000000000..f11be9734c --- /dev/null +++ b/ext/standard/tests/file/statpage.phpt @@ -0,0 +1,20 @@ +--TEST-- +getlastmod() and others +--FILE-- + +--EXPECTF-- +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +Done -- cgit v1.2.1