File tree 2 files changed +29
-8
lines changed
2 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -47,28 +47,29 @@ function toArray() {
47
47
}
48
48
return $ array ;
49
49
}
50
-
50
+
51
51
/**
52
52
* Return all the keys of this map
53
53
*/
54
54
function keys () {
55
- $ array = array ();
55
+ $ output = array ();
56
56
foreach ($ this as $ k => $ v ) {
57
- $ array [] = $ v ;
57
+ $ output [] = $ k ;
58
58
}
59
- return $ array ;
59
+ return $ output ;
60
60
}
61
+
61
62
/**
62
63
* Return all the values of this map
63
64
*/
64
65
function values () {
65
- $ array = array ();
66
+ $ output = array ();
66
67
foreach ($ this as $ k => $ v ) {
67
- $ array [] = $ v ;
68
+ $ output [] = $ v ;
68
69
}
69
- return $ array ;
70
+ return $ output ;
70
71
}
71
-
72
+
72
73
/**
73
74
* Unshift an item onto the start of the map
74
75
*/
Original file line number Diff line number Diff line change @@ -57,6 +57,26 @@ function testToArray() {
57
57
"Phil " => "Phil is a unique guy, and comments on team2 " ), $ map ->toArray ());
58
58
}
59
59
60
+ function testKeys () {
61
+ $ list = DataList::create ('DataObjectTest_TeamComment ' );
62
+ $ map = new SS_Map ($ list , 'Name ' , 'Comment ' );
63
+ $ this ->assertEquals (array (
64
+ 'Joe ' ,
65
+ 'Bob ' ,
66
+ 'Phil '
67
+ ), $ map ->keys ());
68
+ }
69
+
70
+ function testValues () {
71
+ $ list = DataList::create ('DataObjectTest_TeamComment ' );
72
+ $ map = new SS_Map ($ list , 'Name ' , 'Comment ' );
73
+ $ this ->assertEquals (array (
74
+ 'This is a team comment by Joe ' ,
75
+ 'This is a team comment by Bob ' ,
76
+ 'Phil is a unique guy, and comments on team2 '
77
+ ), $ map ->values ());
78
+ }
79
+
60
80
function testUnshift () {
61
81
$ list = DataList::create ("DataObjectTest_TeamComment " );
62
82
$ map = new SS_Map ($ list , 'Name ' , 'Comment ' );
You can’t perform that action at this time.
0 commit comments