summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2013-04-01 19:11:45 +0800
committerXinchen Hui <laruence@php.net>2013-04-01 19:11:45 +0800
commitd8a5f41a606a19efea7fe4df34bb24e66d3d3762 (patch)
treea62fdbd9dab6396d241e538dc2d04f91968ecf2c /ext/standard/tests/array
parent3b504a371734cec343a5b17adc019b54f474b2a9 (diff)
downloadphp-git-d8a5f41a606a19efea7fe4df34bb24e66d3d3762.tar.gz
Fixed bug parameter is casted to string of array_column
Diffstat (limited to 'ext/standard/tests/array')
-rw-r--r--ext/standard/tests/array/array_column_object_cast.phpt52
1 files changed, 52 insertions, 0 deletions
diff --git a/ext/standard/tests/array/array_column_object_cast.phpt b/ext/standard/tests/array/array_column_object_cast.phpt
new file mode 100644
index 0000000000..762aaa81f4
--- /dev/null
+++ b/ext/standard/tests/array/array_column_object_cast.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test array_column() function: basic functionality
+--FILE--
+<?php
+class ColumnKeyClass {
+ function __toString() { return 'first_name'; }
+}
+
+class IndexKeyClass {
+ function __toString() { return 'id'; }
+}
+
+class ValueClass {
+ function __toString() { return '2135'; }
+}
+
+
+$column_key = new ColumnKeyClass();
+$index_key = new IndexKeyClass();
+$value = new ValueClass();
+
+
+// Array representing a possible record set returned from a database
+$records = array(
+ array(
+ 'id' => $value,
+ 'first_name' => 'John',
+ 'last_name' => 'XXX'
+ ),
+ array(
+ 'id' => 3245,
+ 'first_name' => 'Sally',
+ 'last_name' => 'Smith'
+ ),
+);
+$firstNames = array_column($records, $column_key, $index_key);
+print_r($firstNames);
+var_dump($column_key);
+var_dump($index_key);
+var_dump($value);
+--EXPECTF--
+Array
+(
+ [2135] => John
+ [3245] => Sally
+)
+object(ColumnKeyClass)#%d (0) {
+}
+object(IndexKeyClass)#%d (0) {
+}
+object(ValueClass)#%d (0) {
+}