File: array_combine_error2.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (52 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--TEST--
Test array_combine() function : error conditions - empty array
--FILE--
<?php
/* Prototype  : array array_combine(array $keys, array $values)
 * Description: Creates an array by using the elements of the first parameter as keys 
 *              and the elements of the second as the corresponding values 
 * Source code: ext/standard/array.c
*/

echo "*** Testing array_combine() : error conditions specific to array_combine() ***\n";

// Testing array_combine by passing empty arrays to $keys and $values arguments
echo "\n-- Testing array_combine() function with empty arrays --\n";
var_dump( array_combine(array(), array()) );

// Testing array_combine by passing empty array to $keys
echo "\n-- Testing array_combine() function with empty array for \$keys argument --\n";
var_dump( array_combine(array(), array(1, 2)) );

// Testing array_combine by passing empty array to $values
echo "\n-- Testing array_combine() function with empty array for \$values argument --\n";
var_dump( array_combine(array(1, 2), array()) );

// Testing array_combine with arrays having unequal number of elements
echo "\n-- Testing array_combine() function by passing array with unequal number of elements --\n";
var_dump( array_combine(array(1, 2), array(1, 2, 3)) );

echo "Done";
?>
--EXPECTF--
*** Testing array_combine() : error conditions specific to array_combine() ***

-- Testing array_combine() function with empty arrays --
array(0) {
}

-- Testing array_combine() function with empty array for $keys argument --

Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
bool(false)

-- Testing array_combine() function with empty array for $values argument --

Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
bool(false)

-- Testing array_combine() function by passing array with unequal number of elements --

Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
bool(false)
Done