$query = new Query(['model' => $this->tag]); $result = $query->order(['id'])->offset(0)->limit(3)->all()->data(); expect($result)->toEqual([['id' => '1', 'name' => 'High Tech'], ['id' => '2', 'name' => 'Sport'], ['id' => '3', 'name' => 'Computer']]); $result = $query->order(['id'])->offset(3)->limit(3)->all()->data(); expect($result)->toEqual([['id' => '4', 'name' => 'Art'], ['id' => '5', 'name' => 'Science'], ['id' => '6', 'name' => 'City']]); }); it("populates the meta count value", function () { $this->fixtures->populate('tag'); $query = new Query(['model' => $this->tag]); $result = $query->order(['id'])->offset(3)->limit(3)->all(); expect($result->meta())->toEqual(['count' => 6]); }); }); describe("->embed()", function () { it("gets/sets with relationship", function () { $query = new Query(['schema' => new Schema(['connection' => $this->connection])]); $query->embed('relation1.relation2'); $query->embed('relation3', ['conditions' => ['title' => 'hello world']]); expect($query->embed())->toBe(['relation1.relation2' => [], 'relation3' => ['conditions' => ['title' => 'hello world']]]); }); it("loads external relations embed a custom condition on tags", function () { $this->fixtures->populate('gallery'); $this->fixtures->populate('image'); $this->fixtures->populate('image_tag'); $this->fixtures->populate('tag'); $galleries = $this->query->embed(['images' => function ($query) { $query->where(['title' => 'Las Vegas']); }])->order('id')->all(); expect(count($galleries[0]->images))->toBe(1); expect(count($galleries[1]->images))->toBe(0); });