Example #1
0
         $collection = new Collection(['data' => [5, null, 4, true, false, 'bob']]);
         expect($collection)->toHaveLength(6);
     });
 });
 describe("->merge()", function () {
     it("merges two collection", function () {
         $collection = new Collection(['data' => [1, 2, 3]]);
         $collection2 = new Collection(['data' => [4, 5, 6, 7]]);
         $collection->merge($collection2);
         expect($collection->data())->toBe([1, 2, 3, 4, 5, 6, 7]);
     });
     it("merges two collection with key preservation", function () {
         $collection = new Collection(['data' => [1, 2, 3]]);
         $collection2 = new Collection(['data' => [4, 5, 6, 7]]);
         $collection->merge($collection2, true);
         expect($collection->data())->toBe([4, 5, 6, 7]);
     });
 });
 describe("->embed()", function () {
     it("deletages the call up to the schema instance", function () {
         $model = Stub::classname(['extends' => Model::class]);
         $schema = Stub::create();
         $model::config(['schema' => $schema]);
         $galleries = $model::create([], ['type' => 'set']);
         expect($schema)->toReceive('embed')->with($galleries, ['relation1.relation2']);
         $galleries->embed(['relation1.relation2']);
     });
 });
 describe("->data()", function () {
     it("calls `toArray()`", function () {
         $collection = new Collection(['data' => [1 => 1]]);