$r->resource('Tag'); }); $this->connection = $connection; $this->fixtures = new Fixtures(['connection' => $connection, 'fixtures' => ['gallery' => 'Lead\\Resource\\Spec\\Fixture\\Schema\\Gallery', 'gallery_detail' => 'Lead\\Resource\\Spec\\Fixture\\Schema\\GalleryDetail', 'image' => 'Lead\\Resource\\Spec\\Fixture\\Schema\\Image', 'image_tag' => 'Lead\\Resource\\Spec\\Fixture\\Schema\\ImageTag', 'tag' => 'Lead\\Resource\\Spec\\Fixture\\Schema\\Tag']]); }); afterEach(function () { $this->fixtures->drop(); $this->fixtures->reset(); }); it("loads a resource", function () { $this->fixtures->populate('gallery'); $r = $this->router; $route = $r->route('gallery/1', 'GET'); $route->dispatch($this->response); expect($route->params)->toBe(['relation' => null, 'rid' => null, 'resource' => 'gallery', 'id' => '1', 'action' => null]); $data = $route->dispatched->data(); $expected = Gallery::load(1)->first()->data(); expect($data['gallery']->data())->toBe($expected); }); it("loads some related resource", function () { $this->fixtures->populate('gallery'); $this->fixtures->populate('image'); $r = $this->router; $route = $r->route('gallery/1/image', 'GET'); $route->dispatch($this->response); expect($route->params)->toBe(['relation' => 'gallery', 'rid' => '1', 'resource' => 'image', 'id' => null, 'action' => null]); $data = $route->dispatched->data(); $expected = Image::find(['conditions' => ['gallery_id' => 1]])->all()->data(); expect($data['image']->data())->toBe($expected); }); });