@@ -137,7 +137,7 @@ public function testClassShortName()
137
137
$ expectations = [
138
138
['Strings ' , "Strings " ],
139
139
['\Packaged\Helpers\Strings ' , "Strings " ],
140
- [new \Packaged \Helpers \Strings , "Strings " ],
140
+ [new \Packaged \Helpers \Strings () , "Strings " ],
141
141
];
142
142
foreach ($ expectations as $ expect )
143
143
{
@@ -174,7 +174,7 @@ public function testGetNamespace()
174
174
['' , '' ],
175
175
['Strings ' , '' ],
176
176
['\Packaged\Helpers\Strings ' , '\Packaged\Helpers ' ],
177
- [new \Packaged \Helpers \Strings , '\Packaged\Helpers ' ],
177
+ [new \Packaged \Helpers \Strings () , '\Packaged\Helpers ' ],
178
178
];
179
179
foreach ($ expectations as $ expect )
180
180
{
@@ -222,6 +222,32 @@ public function testPpull()
222
222
$ this ->assertEquals ($ expected , Objects::ppull ($ list , null , 'name ' ));
223
223
}
224
224
225
+ public function testApull ()
226
+ {
227
+ $ a = new stdClass ();
228
+ $ a ->name = "a " ;
229
+ $ a ->value1 = 1 ;
230
+ $ a ->value2 = 2 ;
231
+ $ b = new stdClass ();
232
+ $ b ->name = "b " ;
233
+ $ b ->value1 = 2 ;
234
+ $ b ->value2 = 3 ;
235
+ $ c = new stdClass ();
236
+ $ c ->name = "c " ;
237
+ $ c ->value1 = 3 ;
238
+ $ c ->value2 = 4 ;
239
+ $ list = [$ a , $ b , $ c ];
240
+
241
+ $ this ->assertEquals (
242
+ [
243
+ 'a ' => ['value1 ' => 1 , 'value2 ' => 2 ],
244
+ 'b ' => ['value1 ' => 2 , 'value2 ' => 3 ],
245
+ 'c ' => ['value1 ' => 3 , 'value2 ' => 4 ],
246
+ ],
247
+ Objects::apull ($ list , ['value1 ' , 'value2 ' ], 'name ' )
248
+ );
249
+ }
250
+
225
251
public function testMsort ()
226
252
{
227
253
$ a = new MFilterTestHelper ('1 ' , 'a ' , 'q ' );
@@ -251,21 +277,21 @@ public function testMGroup()
251
277
$ expect = [
252
278
'food ' => [
253
279
'fruit ' => ['a ' => $ apple ],
254
- 'vegetable ' => ['c ' => $ carrot ]
280
+ 'vegetable ' => ['c ' => $ carrot ],
255
281
],
256
282
'creature ' => [
257
- 'animal ' => ['b ' => $ bear ]
283
+ 'animal ' => ['b ' => $ bear ],
258
284
],
259
285
];
260
286
$ this ->assertEquals ($ expect , Objects::mgroup ($ list , 'group ' , 'type ' ));
261
287
262
288
$ expect = [
263
289
'food ' => [
264
290
'a ' => $ apple ,
265
- 'c ' => $ carrot
291
+ 'c ' => $ carrot,
266
292
],
267
293
'creature ' => [
268
- 'b ' => $ bear
294
+ 'b ' => $ bear,
269
295
],
270
296
];
271
297
$ this ->assertEquals ($ expect , Objects::mgroup ($ list , 'group ' ));
@@ -289,10 +315,10 @@ public function testPGroup()
289
315
$ expect = [
290
316
'food ' => [
291
317
'fruit ' => ['a ' => $ apple ],
292
- 'vegetable ' => ['c ' => $ carrot ]
318
+ 'vegetable ' => ['c ' => $ carrot ],
293
319
],
294
320
'creature ' => [
295
- 'animal ' => ['b ' => $ bear ]
321
+ 'animal ' => ['b ' => $ bear ],
296
322
],
297
323
];
298
324
$ this ->assertEquals (
@@ -303,10 +329,10 @@ public function testPGroup()
303
329
$ expect = [
304
330
'food ' => [
305
331
'a ' => $ apple ,
306
- 'c ' => $ carrot
332
+ 'c ' => $ carrot,
307
333
],
308
334
'creature ' => [
309
- 'b ' => $ bear
335
+ 'b ' => $ bear,
310
336
],
311
337
];
312
338
$ this ->assertEquals ($ expect , Objects::pgroup ($ list , 'groupProperty ' ));
@@ -326,7 +352,7 @@ public function testPsort()
326
352
["apple " => $ apple , "pear " => $ pear , "grape " => $ grape ],
327
353
"name " ,
328
354
["apple " => $ apple , "grape " => $ grape , "pear " => $ pear ],
329
- ]
355
+ ],
330
356
];
331
357
foreach ($ expectations as $ expect )
332
358
{
0 commit comments