beautify code, ajout méthode pluck et toArray à l'objet collection
This commit is contained in:
@@ -50,5 +50,26 @@ test("collection", function () {
|
||||
return $item + $carry;
|
||||
},$init);
|
||||
expect($reduce)->toBe(55);
|
||||
|
||||
$array = $coll->toArray();
|
||||
expect($array)->toBeArray();
|
||||
expect(count($array))->toBe(11);
|
||||
|
||||
$obj = new \stdClass();
|
||||
$obj->key = "test";
|
||||
$obj->val = 1;
|
||||
|
||||
$obj2 = new \stdClass();
|
||||
$obj2->key = "test2";
|
||||
$obj2->val = 2;
|
||||
|
||||
$collo = new Collection([$obj,$obj2]);
|
||||
expect($collo)->toBeInstanceOf(Collection::class);
|
||||
expect(count($collo))->toBe(2);
|
||||
|
||||
$pluck = $collo->pluck("key");
|
||||
expect($pluck)->toBeInstanceOf(Collection::class);
|
||||
expect(count($pluck))->toBe(2);
|
||||
expect($pluck->first())->toBe("test");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user