Example #1
0
     });
 });
 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);
     });
     it("loads external relations with a custom condition on tags using an array syntax", function () {
         $this->fixtures->populate('gallery');
         $this->fixtures->populate('image');
         $this->fixtures->populate('image_tag');
         $this->fixtures->populate('tag');
         $galleries = $this->query->embed(['images' => ['conditions' => ['title' => 'Las Vegas']]])->order('id')->all();
         expect(count($galleries[0]->images))->toBe(1);
         expect(count($galleries[1]->images))->toBe(0);
     });
 });
 describe("->has()", function () {