Skip to content

Commit a2522ef

Browse files
committed
Add extra ArrayObject::sort() test
1 parent 094c808 commit a2522ef

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
--TEST--
2+
Test sorting of various ArrayObject backing storage
3+
--FILE--
4+
<?php
5+
6+
$obj = (object)['a' => 2, 'b' => 1];
7+
$ao = new ArrayObject($obj);
8+
$ao->uasort(function($a, $b) { return $a <=> $b; });
9+
var_dump($ao);
10+
11+
$ao2 = new ArrayObject($ao);
12+
$ao2->uasort(function($a, $b) { return $b <=> $a; });
13+
var_dump($ao2);
14+
15+
$ao3 = new ArrayObject();
16+
$ao3->exchangeArray($ao3);
17+
$ao3->a = 2;
18+
$ao3->b = 1;
19+
$ao3->uasort(function($a, $b) { return $a <=> $b; });
20+
var_dump($ao3);
21+
22+
$ao4 = new ArrayObject([]);
23+
$ao4->uasort(function($a, $b) { return $a <=> $b; });
24+
var_dump($ao4);
25+
26+
$ao5 = new ArrayObject(['a' => 2, 'b' => 1]);
27+
$ao5->uasort(function($a, $b) { return $a <=> $b; });
28+
var_dump($ao5);
29+
30+
?>
31+
--EXPECT--
32+
object(ArrayObject)#2 (1) {
33+
["storage":"ArrayObject":private]=>
34+
object(stdClass)#1 (2) {
35+
["b"]=>
36+
int(1)
37+
["a"]=>
38+
int(2)
39+
}
40+
}
41+
object(ArrayObject)#3 (1) {
42+
["storage":"ArrayObject":private]=>
43+
object(ArrayObject)#2 (1) {
44+
["storage":"ArrayObject":private]=>
45+
object(stdClass)#1 (2) {
46+
["a"]=>
47+
int(2)
48+
["b"]=>
49+
int(1)
50+
}
51+
}
52+
}
53+
object(ArrayObject)#4 (2) {
54+
["b"]=>
55+
int(1)
56+
["a"]=>
57+
int(2)
58+
}
59+
object(ArrayObject)#5 (1) {
60+
["storage":"ArrayObject":private]=>
61+
array(0) {
62+
}
63+
}
64+
object(ArrayObject)#6 (1) {
65+
["storage":"ArrayObject":private]=>
66+
array(2) {
67+
["b"]=>
68+
int(1)
69+
["a"]=>
70+
int(2)
71+
}
72+
}

0 commit comments

Comments
 (0)