summaryrefslogtreecommitdiff
path: root/ext/standard/tests
diff options
context:
space:
mode:
authorIain Lewis <ilewis@php.net>2008-12-01 16:42:13 +0000
committerIain Lewis <ilewis@php.net>2008-12-01 16:42:13 +0000
commit91ce2d596372a1328f10a9aceee477326f458d00 (patch)
tree2be48004af249f66a2d83b8aeaddaaf40ad55f1a /ext/standard/tests
parent8d161f97cdbb580463562cdf160a2c2d98307e75 (diff)
downloadphp-git-91ce2d596372a1328f10a9aceee477326f458d00.tar.gz
Adding tests for array_multisort
Diffstat (limited to 'ext/standard/tests')
-rw-r--r--ext/standard/tests/array/array_multisort_basic1.phpt60
-rw-r--r--ext/standard/tests/array/array_multisort_basic2.phpt44
-rw-r--r--ext/standard/tests/array/array_multisort_error.phpt44
-rw-r--r--ext/standard/tests/array/array_multisort_variation1.phpt207
-rw-r--r--ext/standard/tests/array/array_multisort_variation10.phpt20
-rw-r--r--ext/standard/tests/array/array_multisort_variation2.phpt228
-rw-r--r--ext/standard/tests/array/array_multisort_variation3.phpt208
-rw-r--r--ext/standard/tests/array/array_multisort_variation4.phpt58
-rw-r--r--ext/standard/tests/array/array_multisort_variation5.phpt53
-rw-r--r--ext/standard/tests/array/array_multisort_variation6.phpt53
-rw-r--r--ext/standard/tests/array/array_multisort_variation7.phpt68
-rw-r--r--ext/standard/tests/array/array_multisort_variation8.phpt74
-rw-r--r--ext/standard/tests/array/array_multisort_variation9.phpt78
13 files changed, 1195 insertions, 0 deletions
diff --git a/ext/standard/tests/array/array_multisort_basic1.phpt b/ext/standard/tests/array/array_multisort_basic1.phpt
new file mode 100644
index 0000000000..af5f8df4f3
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_basic1.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test array_multisort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : basic functionality ***\n";
+
+// Initialise all required variables
+$ar1 = array("row1" => 2, "row2" => 1, "row3" => 1);
+$ar2 = array("row1" => 2, "row2" => "aa", "row3" => "1");
+
+echo "\n-- Testing array_multisort() function with all normal arguments --\n";
+var_dump( array_multisort($ar1, SORT_ASC, SORT_REGULAR, $ar2, SORT_DESC, SORT_STRING) );
+var_dump($ar1, $ar2);
+
+echo "\n-- Testing array_multisort() function with one argument --\n";
+var_dump( array_multisort($ar2) );
+var_dump($ar2);
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : basic functionality ***
+
+-- Testing array_multisort() function with all normal arguments --
+bool(true)
+array(3) {
+ ["row2"]=>
+ int(1)
+ ["row3"]=>
+ int(1)
+ ["row1"]=>
+ int(2)
+}
+array(3) {
+ ["row2"]=>
+ string(2) "aa"
+ ["row3"]=>
+ string(1) "1"
+ ["row1"]=>
+ int(2)
+}
+
+-- Testing array_multisort() function with one argument --
+bool(true)
+array(3) {
+ ["row3"]=>
+ string(1) "1"
+ ["row2"]=>
+ string(2) "aa"
+ ["row1"]=>
+ int(2)
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/array/array_multisort_basic2.phpt b/ext/standard/tests/array/array_multisort_basic2.phpt
new file mode 100644
index 0000000000..d2c7ac20b7
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_basic2.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test array_multisort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : basic functionality - renumbering of numeric keys ***\n";
+
+// Initialise all required variables
+$ar1 = array( "strkey" => 2, 1, 9 => 1);
+$ar2 = array( 2, "aa" , "1");
+
+echo "\n-- Testing array_multisort() function with all normal arguments --\n";
+var_dump( array_multisort($ar1, SORT_ASC, SORT_REGULAR, $ar2, SORT_ASC, SORT_NUMERIC) );
+var_dump($ar1, $ar2);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : basic functionality - renumbering of numeric keys ***
+
+-- Testing array_multisort() function with all normal arguments --
+bool(true)
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ ["strkey"]=>
+ int(2)
+}
+array(3) {
+ [0]=>
+ string(2) "aa"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ int(2)
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/array/array_multisort_error.phpt b/ext/standard/tests/array/array_multisort_error.phpt
new file mode 100644
index 0000000000..7cd95ec169
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test array_multisort() function : error conditions
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing array_multisort() function with Zero arguments --\n";
+var_dump( array_multisort() );
+
+echo "\n-- Testing array_multisort() function with repeated flags --\n";
+$ar1 = array(1);
+var_dump( array_multisort($ar1, SORT_ASC, SORT_ASC) );
+
+echo "\n-- Testing array_multisort() function with repeated flags --\n";
+$ar1 = array(1);
+var_dump( array_multisort($ar1, SORT_STRING, SORT_NUMERIC) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : error conditions ***
+
+-- Testing array_multisort() function with Zero arguments --
+
+Warning: array_multisort() expects at least 1 parameter, 0 given in %sarray_multisort_error.php on line %d
+NULL
+
+-- Testing array_multisort() function with repeated flags --
+
+Warning: array_multisort(): Argument #3 is expected to be an array or sorting flag that has not already been specified in %sarray_multisort_error.php on line %d
+bool(false)
+
+-- Testing array_multisort() function with repeated flags --
+
+Warning: array_multisort(): Argument #3 is expected to be an array or sorting flag that has not already been specified in %sarray_multisort_error.php on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/array/array_multisort_variation1.phpt b/ext/standard/tests/array/array_multisort_variation1.phpt
new file mode 100644
index 0000000000..084addef40
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation1.phpt
@@ -0,0 +1,207 @@
+--TEST--
+Test array_multisort() function : usage variation
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+$ar2 = array(1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for ar1
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( array_multisort($value));
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : usage variation ***
+
+--int 0--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--int 1--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - array_multisort(): Argument #1 is an unknown sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - array_multisort(): Argument #1 is an unknown sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--float .5--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+
+--unset var--
+Error: 2 - array_multisort(): Argument #1 is expected to be an array or a sort flag, %sarray_multisort_variation1.php(%d)
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/array/array_multisort_variation10.phpt b/ext/standard/tests/array/array_multisort_variation10.phpt
new file mode 100644
index 0000000000..4e9f4890ca
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation10.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Test array_multisort() function : usage variation - testing with anonymous arrary arguments
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : Testing with anonymous arguments ***\n";
+
+var_dump(array_multisort(array(1,3,2,4)));
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : Testing with anonymous arguments ***
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation2.phpt b/ext/standard/tests/array/array_multisort_variation2.phpt
new file mode 100644
index 0000000000..bad20188ed
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation2.phpt
@@ -0,0 +1,228 @@
+--TEST--
+Test array_multisort() function : usage variation
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$ar1 = array(1, 2);
+$ar2 = array(1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for SORT_REGULAR|SORT_NUMERIC|SORT_STRING]]
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( array_multisort($ar1, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : usage variation ***
+
+--int 0--
+bool(true)
+
+--int 1--
+bool(true)
+
+--int 12345--
+Error: 2 - array_multisort(): Argument #2 is an unknown sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - array_multisort(): Argument #2 is an unknown sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--float .5--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--empty array--
+Error: 2 - array_multisort(): Array sizes are inconsistent, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - array_multisort(): Array sizes are inconsistent, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--associative array--
+bool(true)
+
+--nested arrays--
+Error: 2 - array_multisort(): Array sizes are inconsistent, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+
+--unset var--
+Error: 2 - array_multisort(): Argument #2 is expected to be an array or a sort flag, %sarray_multisort_variation2.php(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation3.phpt b/ext/standard/tests/array/array_multisort_variation3.phpt
new file mode 100644
index 0000000000..534374c431
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation3.phpt
@@ -0,0 +1,208 @@
+--TEST--
+Test array_multisort() function : usage variation
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$ar1 = array(1, 2);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for ar2
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( array_multisort($ar1, SORT_REGULAR, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : usage variation ***
+
+--int 0--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--int 1--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or sorting flag that has not already been specified, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - array_multisort(): Argument #3 is an unknown sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - array_multisort(): Argument #3 is an unknown sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--float .5--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+
+--unset var--
+Error: 2 - array_multisort(): Argument #3 is expected to be an array or a sort flag, %sarray_multisort_variation3.php(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation4.phpt b/ext/standard/tests/array/array_multisort_variation4.phpt
new file mode 100644
index 0000000000..ce2ae23564
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation4.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test array_multisort() function : usage variation - testing with multiple array arguments
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : Testing with multiple array arguments ***\n";
+
+$arr1 = array (4,3,3,3);
+$arr2 = array (9,3,2,2);
+$arr3 = array (9,9,2,1);
+
+var_dump(array_multisort($arr1, $arr2, $arr3));
+
+var_dump($arr1);
+var_dump($arr2);
+var_dump($arr3);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : Testing with multiple array arguments ***
+bool(true)
+array(4) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(3)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+}
+array(4) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(9)
+}
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(9)
+ [3]=>
+ int(9)
+}
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation5.phpt b/ext/standard/tests/array/array_multisort_variation5.phpt
new file mode 100644
index 0000000000..87e60f22b1
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation5.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test array_multisort() function : usage variation - testing with multiple array arguments
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : Testing all array sort specifiers ***\n";
+
+$ar = array( 2, "aa" , "1");
+
+array_multisort($ar, SORT_REGULAR, SORT_ASC);
+var_dump($ar);
+
+array_multisort($ar, SORT_STRING, SORT_ASC);
+var_dump($ar);
+
+array_multisort($ar, SORT_NUMERIC, SORT_ASC);
+var_dump($ar);
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : Testing all array sort specifiers ***
+array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(2) "aa"
+ [2]=>
+ int(2)
+}
+array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ int(2)
+ [2]=>
+ string(2) "aa"
+}
+array(3) {
+ [0]=>
+ string(2) "aa"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ int(2)
+}
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation6.phpt b/ext/standard/tests/array/array_multisort_variation6.phpt
new file mode 100644
index 0000000000..9774d49bad
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation6.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test array_multisort() function : usage variation - testing with multiple array arguments
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : Testing all array sort specifiers ***\n";
+
+$ar = array( 2, "aa" , "1");
+
+array_multisort($ar, SORT_REGULAR, SORT_DESC);
+var_dump($ar);
+
+array_multisort($ar, SORT_STRING, SORT_DESC);
+var_dump($ar);
+
+array_multisort($ar, SORT_NUMERIC, SORT_DESC);
+var_dump($ar);
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : Testing all array sort specifiers ***
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ string(2) "aa"
+ [2]=>
+ string(1) "1"
+}
+array(3) {
+ [0]=>
+ string(2) "aa"
+ [1]=>
+ int(2)
+ [2]=>
+ string(1) "1"
+}
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ string(1) "1"
+ [2]=>
+ string(2) "aa"
+}
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation7.phpt b/ext/standard/tests/array/array_multisort_variation7.phpt
new file mode 100644
index 0000000000..c8ca24013a
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation7.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Test array_multisort() function : usage variation - test sort order of all types
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : usage variation - test sort order of all types***\n";
+
+// define some classes
+class classWithToString {
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString { }
+
+$inputs = array(
+ 'int 0' => 0,
+ 'float -10.5' => -10.5,
+ array(),
+ 'uppercase NULL' => NULL,
+ 'lowercase true' => true,
+ 'empty string DQ' => "",
+ 'string DQ' => "string",
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+ 'undefined var' => @$undefined_var,
+);
+
+var_dump(array_multisort($inputs));
+var_dump($inputs);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : usage variation - test sort order of all types***
+bool(true)
+array(10) {
+ ["empty string DQ"]=>
+ string(0) ""
+ ["int 0"]=>
+ int(0)
+ ["uppercase NULL"]=>
+ NULL
+ ["undefined var"]=>
+ NULL
+ [0]=>
+ array(0) {
+ }
+ ["instance of classWithToString"]=>
+ object(classWithToString)#1 (0) {
+ }
+ ["instance of classWithoutToString"]=>
+ object(classWithoutToString)#2 (0) {
+ }
+ ["lowercase true"]=>
+ bool(true)
+ ["float -10.5"]=>
+ float(-10.5)
+ ["string DQ"]=>
+ string(6) "string"
+}
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation8.phpt b/ext/standard/tests/array/array_multisort_variation8.phpt
new file mode 100644
index 0000000000..60f7a97e32
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation8.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Test array_multisort() function : usage variation - test sort order of all types
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : usage variation - test sort order of all types***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ // We're testing sort order not errors so ignore.
+}
+set_error_handler('test_error_handler');
+
+// define some classes
+class classWithToString {
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString { }
+
+$inputs = array(
+ 'int 0' => 0,
+ 'float -10.5' => -10.5,
+ array(),
+ 'uppercase NULL' => NULL,
+ 'lowercase true' => true,
+ 'empty string DQ' => "",
+ 'string DQ' => "string",
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+ 'undefined var' => @$undefined_var,
+);
+
+var_dump(array_multisort($inputs, SORT_STRING));
+var_dump($inputs);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : usage variation - test sort order of all types***
+bool(true)
+array(10) {
+ ["empty string DQ"]=>
+ string(0) ""
+ ["uppercase NULL"]=>
+ NULL
+ ["undefined var"]=>
+ NULL
+ ["instance of classWithoutToString"]=>
+ object(classWithoutToString)#2 (0) {
+ }
+ ["float -10.5"]=>
+ float(-10.5)
+ ["int 0"]=>
+ int(0)
+ ["lowercase true"]=>
+ bool(true)
+ [0]=>
+ array(0) {
+ }
+ ["instance of classWithToString"]=>
+ object(classWithToString)#1 (0) {
+ }
+ ["string DQ"]=>
+ string(6) "string"
+}
+===DONE===
diff --git a/ext/standard/tests/array/array_multisort_variation9.phpt b/ext/standard/tests/array/array_multisort_variation9.phpt
new file mode 100644
index 0000000000..98ccd06ed0
--- /dev/null
+++ b/ext/standard/tests/array/array_multisort_variation9.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test array_multisort() function : usage variation - test sort order of all types
+--FILE--
+<?php
+/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING]], ...])
+ * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL
+ * Source code: ext/standard/array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing array_multisort() : usage variation - test sort order of all types***\n";
+
+// define some classes
+class classWithToString {
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString { }
+
+$inputs = array(
+ 'int 0' => 0,
+ 'float -10.5' => -10.5,
+ array(),
+ 'uppercase NULL' => NULL,
+ 'lowercase true' => true,
+ 'empty string DQ' => "",
+ 'string DQ' => "string",
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+ 'undefined var' => @$undefined_var,
+);
+
+var_dump(array_multisort($inputs, SORT_NUMERIC));
+var_dump($inputs);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing array_multisort() : usage variation - test sort order of all types***
+
+Notice: Object of class classWithToString could not be converted to double in %sarray_multisort_variation9.php on line %d
+
+Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
+
+Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
+
+Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
+
+Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
+bool(true)
+array(10) {
+ ["float -10.5"]=>
+ float(-10.5)
+ ["string DQ"]=>
+ string(6) "string"
+ ["undefined var"]=>
+ NULL
+ ["empty string DQ"]=>
+ string(0) ""
+ ["uppercase NULL"]=>
+ NULL
+ ["int 0"]=>
+ int(0)
+ [0]=>
+ array(0) {
+ }
+ ["instance of classWithoutToString"]=>
+ object(classWithoutToString)#2 (0) {
+ }
+ ["lowercase true"]=>
+ bool(true)
+ ["instance of classWithToString"]=>
+ object(classWithToString)#1 (0) {
+ }
+}
+===DONE=== \ No newline at end of file