From e100d53bff1f1ab0e887cfe492d74af32decb224 Mon Sep 17 00:00:00 2001 From: Josie Messa Date: Wed, 13 Feb 2008 16:40:42 +0000 Subject: [PATCH] - New tests for array_shift() function --- .../tests/array/array_shift_basic.phpt | 81 +++++ .../tests/array/array_shift_error.phpt | 53 +++ .../tests/array/array_shift_variation1.phpt | 341 ++++++++++++++++++ .../tests/array/array_shift_variation2.phpt | 295 +++++++++++++++ .../tests/array/array_shift_variation3.phpt | 271 ++++++++++++++ .../tests/array/array_shift_variation4.phpt | 180 +++++++++ .../tests/array/array_shift_variation5.phpt | 58 +++ .../tests/array/array_shift_variation6.phpt | 127 +++++++ .../tests/array/array_shift_variation7.phpt | 43 +++ .../tests/array/array_shift_variation8.phpt | 61 ++++ 10 files changed, 1510 insertions(+) create mode 100644 ext/standard/tests/array/array_shift_basic.phpt create mode 100644 ext/standard/tests/array/array_shift_error.phpt create mode 100644 ext/standard/tests/array/array_shift_variation1.phpt create mode 100644 ext/standard/tests/array/array_shift_variation2.phpt create mode 100644 ext/standard/tests/array/array_shift_variation3.phpt create mode 100644 ext/standard/tests/array/array_shift_variation4.phpt create mode 100644 ext/standard/tests/array/array_shift_variation5.phpt create mode 100644 ext/standard/tests/array/array_shift_variation6.phpt create mode 100644 ext/standard/tests/array/array_shift_variation7.phpt create mode 100644 ext/standard/tests/array/array_shift_variation8.phpt diff --git a/ext/standard/tests/array/array_shift_basic.phpt b/ext/standard/tests/array/array_shift_basic.phpt new file mode 100644 index 0000000000..74aea48bf3 --- /dev/null +++ b/ext/standard/tests/array/array_shift_basic.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test array_shift() function : basic functionality +--FILE-- + 'three', 'four' => 4); +echo "\n-- Before shift: --\n"; +var_dump($array); + +echo "\n-- After shift: --\n"; +echo "Returned value:\t"; +var_dump(array_shift($array)); +echo "New array:\n"; +var_dump($array); + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_shift() : basic functionality *** + +-- Before shift: -- +array(4) { + [0]=> + string(4) "zero" + [1]=> + string(3) "one" + [3]=> + string(5) "three" + ["four"]=> + int(4) +} + +-- After shift: -- +Returned value: string(4) "zero" +New array: +array(3) { + [0]=> + string(3) "one" + [1]=> + string(5) "three" + ["four"]=> + int(4) +} +Done +--UEXPECTF-- +*** Testing array_shift() : basic functionality *** + +-- Before shift: -- +array(4) { + [0]=> + unicode(4) "zero" + [1]=> + unicode(3) "one" + [3]=> + unicode(5) "three" + [u"four"]=> + int(4) +} + +-- After shift: -- +Returned value: unicode(4) "zero" +New array: +array(3) { + [0]=> + unicode(3) "one" + [1]=> + unicode(5) "three" + [u"four"]=> + int(4) +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_error.phpt b/ext/standard/tests/array/array_shift_error.phpt new file mode 100644 index 0000000000..0c0d4d3b43 --- /dev/null +++ b/ext/standard/tests/array/array_shift_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test array_shift() function : error conditions - Pass incorrect number of args +--FILE-- + +--EXPECTF-- +*** Testing array_shift() : error conditions *** + +-- Testing array_shift() function with Zero arguments -- + +Warning: array_shift() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing array_shift() function with more than expected no. of arguments -- + +Warning: array_shift() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing array_shift() : error conditions *** + +-- Testing array_shift() function with Zero arguments -- + +Warning: array_shift() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing array_shift() function with more than expected no. of arguments -- + +Warning: array_shift() expects exactly 1 parameter, 2 given in %s on line %d +NULL +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation1.phpt b/ext/standard/tests/array/array_shift_variation1.phpt new file mode 100644 index 0000000000..ad02590c44 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation1.phpt @@ -0,0 +1,341 @@ +--TEST-- +Test array_shift() function : usage variations - Pass different data types as $stack arg +--FILE-- + +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Iteration 1 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: array_shift() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: array_shift() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: array_shift() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: array_shift() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: array_shift() expects parameter 1 to be array, string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: array_shift() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: array_shift() expects parameter 1 to be array, resource given in %s on line 85 +NULL +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Iteration 1 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: array_shift() expects parameter 1 to be array, integer given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: array_shift() expects parameter 1 to be array, double given in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: array_shift() expects parameter 1 to be array, boolean given in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: array_shift() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: array_shift() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: array_shift() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: array_shift() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: array_shift() expects parameter 1 to be array, Unicode string given in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: array_shift() expects parameter 1 to be array, object given in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: array_shift() expects parameter 1 to be array, null given in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: array_shift() expects parameter 1 to be array, resource given in %s on line %d +NULL +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation2.phpt b/ext/standard/tests/array/array_shift_variation2.phpt new file mode 100644 index 0000000000..e4e83851b8 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation2.phpt @@ -0,0 +1,295 @@ +--TEST-- +Test array_shift() function : usage variations - Pass arrays of different data types +--FILE-- + array( + 0, + 1, + 12345, + -2345, + ), + + // float data +/*2*/ 'float' => array( + 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + ), + + // null data +/*3*/ 'null' => array( + NULL, + null, + ), + + // boolean data +/*4*/ 'bool' => array( + true, + false, + TRUE, + FALSE, + ), + + // empty data +/*5*/ 'empty string' => array( + "", + '', + ), + +/*6*/ 'empty array' => array( + ), + + // string data +/*7*/ 'string' => array( + "string", + 'string', + $heredoc, + ), + + // object data +/*8*/ 'object' => array( + new classA(), + ), + + // undefined data +/*9*/ 'undefined' => array( + @$undefined_var, + ), + + // unset data +/*10*/ 'unset' => array( + @$unset_var, + ), + + // resource variable +/*11*/ 'resource' => array( + $fp + ), +); + +// loop through each element of $inputs to check the behavior of array_shift +$iterator = 1; +foreach($inputs as $key => $input) { + echo "\n-- Iteration $iterator: $key data --\n"; + var_dump( array_shift($input) ); + var_dump($input); + $iterator++; +}; + +fclose($fp); + + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Iteration 1: int data -- +int(0) +array(3) { + [0]=> + int(1) + [1]=> + int(12345) + [2]=> + int(-2345) +} + +-- Iteration 2: float data -- +float(10.5) +array(4) { + [0]=> + float(-10.5) + [1]=> + float(123456789000) + [2]=> + float(1.23456789E-9) + [3]=> + float(0.5) +} + +-- Iteration 3: null data -- +NULL +array(1) { + [0]=> + NULL +} + +-- Iteration 4: bool data -- +bool(true) +array(3) { + [0]=> + bool(false) + [1]=> + bool(true) + [2]=> + bool(false) +} + +-- Iteration 5: empty string data -- +string(0) "" +array(1) { + [0]=> + string(0) "" +} + +-- Iteration 6: empty array data -- +NULL +array(0) { +} + +-- Iteration 7: string data -- +string(6) "string" +array(2) { + [0]=> + string(6) "string" + [1]=> + string(11) "hello world" +} + +-- Iteration 8: object data -- +object(classA)#%d (0) { +} +array(0) { +} + +-- Iteration 9: undefined data -- +NULL +array(0) { +} + +-- Iteration 10: unset data -- +NULL +array(0) { +} + +-- Iteration 11: resource data -- +resource(%d) of type (stream) +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Iteration 1: int data -- +int(0) +array(3) { + [0]=> + int(1) + [1]=> + int(12345) + [2]=> + int(-2345) +} + +-- Iteration 2: float data -- +float(10.5) +array(4) { + [0]=> + float(-10.5) + [1]=> + float(123456789000) + [2]=> + float(1.23456789E-9) + [3]=> + float(0.5) +} + +-- Iteration 3: null data -- +NULL +array(1) { + [0]=> + NULL +} + +-- Iteration 4: bool data -- +bool(true) +array(3) { + [0]=> + bool(false) + [1]=> + bool(true) + [2]=> + bool(false) +} + +-- Iteration 5: empty string data -- +unicode(0) "" +array(1) { + [0]=> + unicode(0) "" +} + +-- Iteration 6: empty array data -- +NULL +array(0) { +} + +-- Iteration 7: string data -- +unicode(6) "string" +array(2) { + [0]=> + unicode(6) "string" + [1]=> + unicode(11) "hello world" +} + +-- Iteration 8: object data -- +object(classA)#%d (0) { +} +array(0) { +} + +-- Iteration 9: undefined data -- +NULL +array(0) { +} + +-- Iteration 10: unset data -- +NULL +array(0) { +} + +-- Iteration 11: resource data -- +resource(%d) of type (stream) +array(0) { +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation3.phpt b/ext/standard/tests/array/array_shift_variation3.phpt new file mode 100644 index 0000000000..6d0264ad15 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation3.phpt @@ -0,0 +1,271 @@ +--TEST-- +Test array_shift() function : usage variations - Pass array with different data types as keys +--FILE-- + array( + 0 => 'zero', + 1 => 'one', + 12345 => 'positive', + -2345 => 'negative', + ), + + // float data +/*2*/ 'float' => array( + 10.5 => 'positive', + -10.5 => 'negative', + .5 => 'half', + ), + +/*3*/ 'extreme floats' => array( + 12.3456789000e10 => 'large', + 12.3456789000E-10 => 'small', + ), + + // null data +/*4*/ 'null uppercase' => array( + NULL => 'null 1', + ), + +/*5*/ 'null lowercase' => array( + null => 'null 2', + ), + + // boolean data +/*6*/ 'bool lowercase' => array( + true => 'lowert', + false => 'lowerf', + ), + +/*7*/ 'bool uppercase' => array( + TRUE => 'uppert', + FALSE => 'upperf', + ), + + // empty data +/*8*/ 'empty double quotes' => array( + "" => 'emptyd', + ), + +/*9*/ 'empty single quotes' => array( + '' => 'emptys', + ), + + // string data +/*10*/ 'string' => array( + "stringd" => 'stringd', + 'strings' => 'strings', + $heredoc => 'stringh', + ), + + // undefined data +/*11*/ 'undefined' => array( + @$undefined_var => 'undefined', + ), + + // unset data +/*12*/ 'unset' => array( + @$unset_var => 'unset', + ), +); + +// loop through each element of $inputs to check the behavior of array_shift() +$iterator = 1; +foreach($inputs as $key => $input) { + echo "\n-- Iteration $iterator : $key data --\n"; + var_dump( array_shift($input) ); + var_dump($input); + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Iteration 1 : int data -- +string(4) "zero" +array(3) { + [0]=> + string(3) "one" + [1]=> + string(8) "positive" + [2]=> + string(8) "negative" +} + +-- Iteration 2 : float data -- +string(8) "positive" +array(2) { + [0]=> + string(8) "negative" + [1]=> + string(4) "half" +} + +-- Iteration 3 : extreme floats data -- +string(5) "large" +array(1) { + [0]=> + string(5) "small" +} + +-- Iteration 4 : null uppercase data -- +string(6) "null 1" +array(0) { +} + +-- Iteration 5 : null lowercase data -- +string(6) "null 2" +array(0) { +} + +-- Iteration 6 : bool lowercase data -- +string(6) "lowert" +array(1) { + [0]=> + string(6) "lowerf" +} + +-- Iteration 7 : bool uppercase data -- +string(6) "uppert" +array(1) { + [0]=> + string(6) "upperf" +} + +-- Iteration 8 : empty double quotes data -- +string(6) "emptyd" +array(0) { +} + +-- Iteration 9 : empty single quotes data -- +string(6) "emptys" +array(0) { +} + +-- Iteration 10 : string data -- +string(7) "stringd" +array(2) { + ["strings"]=> + string(7) "strings" + ["hello world"]=> + string(7) "stringh" +} + +-- Iteration 11 : undefined data -- +string(9) "undefined" +array(0) { +} + +-- Iteration 12 : unset data -- +string(5) "unset" +array(0) { +} +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Iteration 1 : int data -- +unicode(4) "zero" +array(3) { + [0]=> + unicode(3) "one" + [1]=> + unicode(8) "positive" + [2]=> + unicode(8) "negative" +} + +-- Iteration 2 : float data -- +unicode(8) "positive" +array(2) { + [0]=> + unicode(8) "negative" + [1]=> + unicode(4) "half" +} + +-- Iteration 3 : extreme floats data -- +unicode(5) "large" +array(1) { + [0]=> + unicode(5) "small" +} + +-- Iteration 4 : null uppercase data -- +unicode(6) "null 1" +array(0) { +} + +-- Iteration 5 : null lowercase data -- +unicode(6) "null 2" +array(0) { +} + +-- Iteration 6 : bool lowercase data -- +unicode(6) "lowert" +array(1) { + [0]=> + unicode(6) "lowerf" +} + +-- Iteration 7 : bool uppercase data -- +unicode(6) "uppert" +array(1) { + [0]=> + unicode(6) "upperf" +} + +-- Iteration 8 : empty double quotes data -- +unicode(6) "emptyd" +array(0) { +} + +-- Iteration 9 : empty single quotes data -- +unicode(6) "emptys" +array(0) { +} + +-- Iteration 10 : string data -- +unicode(7) "stringd" +array(2) { + [u"strings"]=> + unicode(7) "strings" + [u"hello world"]=> + unicode(7) "stringh" +} + +-- Iteration 11 : undefined data -- +unicode(9) "undefined" +array(0) { +} + +-- Iteration 12 : unset data -- +unicode(5) "unset" +array(0) { +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation4.phpt b/ext/standard/tests/array/array_shift_variation4.phpt new file mode 100644 index 0000000000..29d5510058 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation4.phpt @@ -0,0 +1,180 @@ +--TEST-- +Test array_shift() function : usage variations - multi-dimensional arrays +--FILE-- + +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Before shift: -- +---- $stack_first: +array(3) { + [0]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [1]=> + string(3) "one" + [2]=> + string(3) "two" +} +---- $stack_last: +array(3) { + [0]=> + string(4) "zero" + [1]=> + string(3) "one" + [2]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- After shift: -- +---- Pop array from array: +Returned value: array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +New array: +array(2) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" +} +---- Pop element from array within array: +Returned value: int(1) +New array: +array(3) { + [0]=> + string(4) "zero" + [1]=> + string(3) "one" + [2]=> + array(2) { + [0]=> + int(2) + [1]=> + int(3) + } +} +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Before shift: -- +---- $stack_first: +array(3) { + [0]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + [1]=> + unicode(3) "one" + [2]=> + unicode(3) "two" +} +---- $stack_last: +array(3) { + [0]=> + unicode(4) "zero" + [1]=> + unicode(3) "one" + [2]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- After shift: -- +---- Pop array from array: +Returned value: array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +New array: +array(2) { + [0]=> + unicode(3) "one" + [1]=> + unicode(3) "two" +} +---- Pop element from array within array: +Returned value: int(1) +New array: +array(3) { + [0]=> + unicode(4) "zero" + [1]=> + unicode(3) "one" + [2]=> + array(2) { + [0]=> + int(2) + [1]=> + int(3) + } +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation5.phpt b/ext/standard/tests/array/array_shift_variation5.phpt new file mode 100644 index 0000000000..548d7a758b --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation5.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test array_shift() function : usage variations - call recursively +--FILE-- + +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Incorrect Method: -- + +Strict Standards: Only variables should be passed by reference in %s on line %d + +Strict Standards: Only variables should be passed by reference in %s on line %d +string(4) "zero" + +-- Correct Method: -- +string(4) "zero" +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Incorrect Method: -- + +Strict Standards: Only variables should be passed by reference in %s on line %d + +Strict Standards: Only variables should be passed by reference in %s on line %d +unicode(4) "zero" + +-- Correct Method: -- +unicode(4) "zero" +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation6.phpt b/ext/standard/tests/array/array_shift_variation6.phpt new file mode 100644 index 0000000000..3794adc921 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation6.phpt @@ -0,0 +1,127 @@ +--TEST-- +Test array_shift() function : usage variations - Referenced arrays +--FILE-- + +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Variable is referenced array -- +Result: string(4) "zero" + +$original_array: +array(2) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" +} + +$copied_array: +array(2) { + [0]=> + string(3) "one" + [1]=> + string(3) "two" +} + +-- Element is referenced array -- +Result: string(3) "one" + +$new_array: +array(3) { + [0]=> + &array(1) { + [0]=> + string(3) "two" + } + [1]=> + int(1) + [2]=> + string(3) "two" +} + +$copied_array +array(1) { + [0]=> + string(3) "two" +} +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Variable is referenced array -- +Result: unicode(4) "zero" + +$original_array: +array(2) { + [0]=> + unicode(3) "one" + [1]=> + unicode(3) "two" +} + +$copied_array: +array(2) { + [0]=> + unicode(3) "one" + [1]=> + unicode(3) "two" +} + +-- Element is referenced array -- +Result: unicode(3) "one" + +$new_array: +array(3) { + [0]=> + &array(1) { + [0]=> + unicode(3) "two" + } + [1]=> + int(1) + [2]=> + unicode(3) "two" +} + +$copied_array +array(1) { + [0]=> + unicode(3) "two" +} +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation7.phpt b/ext/standard/tests/array/array_shift_variation7.phpt new file mode 100644 index 0000000000..8e00473a74 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation7.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test array_shift() function : usage variations - position of internal pointer +--FILE-- + 'un', 'two' => 'deux'); + +echo "\n-- Call array_shift() --\n"; +var_dump($result = array_shift($stack)); + +echo "\n-- Position of Internal Pointer in Passed Array: --\n"; +echo key($stack) . " => " . current ($stack) . "\n"; + +echo "Done"; +?> +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Call array_shift() -- +string(2) "un" + +-- Position of Internal Pointer in Passed Array: -- +two => deux +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Call array_shift() -- +unicode(2) "un" + +-- Position of Internal Pointer in Passed Array: -- +two => deux +Done \ No newline at end of file diff --git a/ext/standard/tests/array/array_shift_variation8.phpt b/ext/standard/tests/array/array_shift_variation8.phpt new file mode 100644 index 0000000000..3f49a459d0 --- /dev/null +++ b/ext/standard/tests/array/array_shift_variation8.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test array_shift() function : usage variations - maintaining referenced elements +--FILE-- + +--EXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Reference result of array_shift: -- + +Strict Standards: Only variables should be assigned by reference in %s on line %d +a = 1, b = 2 + +-- Reference first element before array_shift: -- +a = 2, b = 2 +Done +--UEXPECTF-- +*** Testing array_shift() : usage variations *** + +-- Reference result of array_shift: -- + +Strict Standards: Only variables should be assigned by reference in %s on line %d +a = 1, b = 2 + +-- Reference first element before array_shift: -- +a = 2, b = 2 +Done \ No newline at end of file -- 2.40.0