smantoor Thu Sep 11 10:41:01 2008 UTC
Added files:
/php-src/ext/standard/tests/array
array_intersect_key_variation2.phpt
array_intersect_key_variation3.phpt
array_intersect_key_error.phpt
array_intersect_key_variation4.phpt
array_intersect_key_variation5.phpt
array_intersect_key_variation6.phpt
array_intersect_key_variation7.phpt
array_intersect_key_variation8.phpt
array_intersect_key_variation1.phpt
Log:
New testcases for array_intersect_key() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation2.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation2.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing unexpected
values to second argument
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array3 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//resource variable
$fp = fopen(__FILE__, "r");
// 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' => -12345,
// 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,
// resource data
'resource var' => $fp,
);
// loop through each element of the array for arr2
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_intersect_key($array1, $value) );
var_dump( array_intersect_key($array1, $value, $array3) );
}
fclose($fp);
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
--int 0--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--int 1--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--int 12345--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--int -12345--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--float 10.5--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--float -10.5--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--float 12.3456789000e10--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--float -12.3456789000e10--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--float .5--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--uppercase NULL--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--lowercase null--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--lowercase true--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--lowercase false--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--uppercase TRUE--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--uppercase FALSE--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--empty string DQ--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--empty string SQ--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--string DQ--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--string SQ--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--mixed case string--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--heredoc--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--instance of classWithToString--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--instance of classWithoutToString--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--undefined var--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--unset var--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
--resource var--
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #2 is not an array in %s on line %d
NULL
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation3.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation3.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing unexpected
values to optional argument
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//resource variable
$fp = fopen(__FILE__, "r");
// 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' => -12345,
// 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,
// resource data
'resource var' => $fp,
);
// loop through each element of the array for arr2
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_intersect_key($array1, $array2, $value) );
}
fclose($fp);
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
--int 0--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--int 1--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--int 12345--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--int -12345--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--float 10.5--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--float -10.5--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--float 12.3456789000e10--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--float -12.3456789000e10--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--float .5--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--uppercase NULL--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--lowercase null--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--lowercase true--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--lowercase false--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--uppercase TRUE--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--uppercase FALSE--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--empty string DQ--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--empty string SQ--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--string DQ--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--string SQ--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--mixed case string--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--heredoc--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--instance of classWithToString--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--instance of classWithoutToString--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--undefined var--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--unset var--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
--resource var--
Warning: array_intersect_key(): Argument #3 is not an array in %s on line %d
NULL
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_error.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_error.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_error.phpt
--TEST--
Test array_intersect_key() function : error conditions
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : error conditions ***\n";
//Initialise function arguments
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
// Testing array_intersect_key with one less than the expected number of
arguments
echo "\n-- Testing array_intersect_key() function with less than expected no.
of arguments --\n";
var_dump( array_intersect_key($array1) );
// Testing array_intersect_key with one less than the expected number of
arguments
echo "\n-- Testing array_intersect_key() function with no arguments --\n";
var_dump( array_intersect_key() );
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : error conditions ***
-- Testing array_intersect_key() function with less than expected no. of
arguments --
Warning: array_intersect_key(): at least 2 parameters are required, 1 given in
%s on line %d
NULL
-- Testing array_intersect_key() function with no arguments --
Warning: array_intersect_key(): at least 2 parameters are required, 0 given in
%s on line %d
NULL
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation4.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation4.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing integer indexed
array
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(0 => '0', -1 => '-1' , 02 => 'two', -07 => '-07', 0xA =>
'0xA', -0xC => '-0xc');
$input_arrays = array(
'decimal indexed' => array(10 => '10', '-17' => '-17'),
'octal indexed' => array(-011 => '-011', 012 => '012'),
'hexa indexed' => array(0x12 => '0x12', -0x7 => '-0x7', ),
);
foreach($input_arrays as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_intersect_key($input_array, $value) );
var_dump( array_intersect_key($value,$input_array ) );
}
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
--decimal indexed--
array(1) {
[10]=>
unicode(3) "0xA"
}
array(1) {
[10]=>
unicode(2) "10"
}
--octal indexed--
array(1) {
[10]=>
unicode(3) "0xA"
}
array(1) {
[10]=>
unicode(3) "012"
}
--hexa indexed--
array(1) {
[-7]=>
unicode(3) "-07"
}
array(1) {
[-7]=>
unicode(4) "-0x7"
}
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation5.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation5.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation5.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing float indexed
array
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(0 => '0', 10 => '10' , -10 => '-10');
$float_indx_array = array(0.0 => '0.0', 10.5 => '10.5' , -10.5 => '-10.5', 0.5
=> '0.5');
echo "\n-- Testing array_intersect_key() function with float indexed array
--\n";
var_dump( array_intersect_key($input_array, $float_indx_array) );
var_dump( array_intersect_key($float_indx_array,$input_array ) );
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
-- Testing array_intersect_key() function with float indexed array --
array(3) {
[0]=>
unicode(1) "0"
[10]=>
unicode(2) "10"
[-10]=>
unicode(3) "-10"
}
array(3) {
[0]=>
unicode(3) "0.5"
[10]=>
unicode(4) "10.5"
[-10]=>
unicode(5) "-10.5"
}
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation6.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation6.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation6.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing boolean indexed
array
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(0 => '0', 1 => '1' , -10 => '-10');
$boolean_indx_array = array(true => 'boolt', false => 'boolf', TRUE => 'boolT',
FALSE => 'boolF');
echo "\n-- Testing array_intersect_key() function with boolean indexed array
--\n";
var_dump( array_intersect_key($input_array, $boolean_indx_array) );
var_dump( array_intersect_key($boolean_indx_array,$input_array ) );
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
-- Testing array_intersect_key() function with boolean indexed array --
array(2) {
[0]=>
unicode(1) "0"
[1]=>
unicode(1) "1"
}
array(2) {
[1]=>
unicode(5) "boolT"
[0]=>
unicode(5) "boolF"
}
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation7.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation7.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation7.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing null,unset and
undefeined variable indexed array
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$input_array = array(0 => '0', 1 => '1' , -10 => '-10' , null => 'null');
//get an unset variable
$unset_var = 10;
unset ($unset_var);
$input_arrays = array(
'null indexed' => array(NULL => 'null 1', null => 'null 2'),
'undefined indexed' => array(@$undefined_var => 'undefined'),
'unset indexed' => array(@$unset_var => 'unset'),
);
foreach($input_arrays as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_intersect_key($input_array, $value) );
var_dump( array_intersect_key($value,$input_array ) );
}
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
--null indexed--
array(1) {
[u""]=>
unicode(4) "null"
}
array(1) {
[u""]=>
unicode(6) "null 2"
}
--undefined indexed--
array(1) {
[u""]=>
unicode(4) "null"
}
array(1) {
[u""]=>
unicode(9) "undefined"
}
--unset indexed--
array(1) {
[u""]=>
unicode(4) "null"
}
array(1) {
[u""]=>
unicode(5) "unset"
}
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation8.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation8.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation8.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing Multi
dimensional array
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
/// Initialise function arguments not being substituted (if any)
$array1 = array(
'first' => array('blue' => 1, 'red' => 2),
'second' => array('yellow' => 7),
'third' => array(0 =>'zero'),
);
$array2 = array (
'first' => array('blue' => 1, 'red' => 2,),
'second' => array('cyan' => 8),
'fourth' => array(2 => 'two'),
);
var_dump( array_intersect_key($array1, $array2) );
var_dump( array_intersect_key($array2,$array1 ) );
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
array(2) {
[u"first"]=>
array(2) {
[u"blue"]=>
int(1)
[u"red"]=>
int(2)
}
[u"second"]=>
array(1) {
[u"yellow"]=>
int(7)
}
}
array(2) {
[u"first"]=>
array(2) {
[u"blue"]=>
int(1)
[u"red"]=>
int(2)
}
[u"second"]=>
array(1) {
[u"cyan"]=>
int(8)
}
}
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_intersect_key_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_intersect_key_variation1.phpt
+++ php-src/ext/standard/tests/array/array_intersect_key_variation1.phpt
--TEST--
Test array_intersect_key() function : usage variation - Passing unexpected
values to first argument
--FILE--
<?php
/* Prototype : array array_intersect_key(array arr1, array arr2 [, array ...])
* Description: Returns the entries of arr1 that have keys which are present in
all the other arguments.
* Source code: ext/standard/array.c
*/
echo "*** Testing array_intersect_key() : usage variation ***\n";
// Initialise function arguments not being substituted (if any)
$array2 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array3 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
//get an unset variable
$unset_var = 10;
unset ($unset_var);
//resource variable
$fp = fopen(__FILE__, "r");
// 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' => -12345,
// 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,
// resource data
'resource var' => $fp,
);
// loop through each element of the array for arr1
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
var_dump( array_intersect_key($value, $array2) );
var_dump( array_intersect_key($value, $array2, $array3) );
}
fclose($fp);
?>
===DONE===
--EXPECTF--
*** Testing array_intersect_key() : usage variation ***
--int 0--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--int 1--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--int 12345--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--int -12345--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--float 10.5--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--float -10.5--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--float 12.3456789000e10--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--float -12.3456789000e10--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--float .5--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--uppercase NULL--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--lowercase null--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--lowercase true--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--lowercase false--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--uppercase TRUE--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--uppercase FALSE--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--empty string DQ--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--empty string SQ--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--string DQ--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--string SQ--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--mixed case string--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--heredoc--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--instance of classWithToString--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--instance of classWithoutToString--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--undefined var--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--unset var--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
--resource var--
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
Warning: array_intersect_key(): Argument #1 is not an array in %s on line %d
NULL
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php