public function test_finding_a_category_by_its_id() { $repo = new CategoryRepository(); $category = Factory::create(new Category()); $response = $repo->findById($category->id); $this->assertEquals($category->id, $response->id); $this->setExpectedException('Illuminate\\Database\\Eloquent\\ModelNotFoundException'); $response = $repo->findById(0); }
/** * Fetch the category and products * * @return void */ public function onRun() { try { if ($slug = $this->property('slug')) { $slug = $this->property('slug'); $this->category = $this->repository->findBySlug($slug); } else { $default = $this->property('default'); $this->category = $this->repository->findById($default); } $page = 1; $this->products = $this->repository->getProducts($this->category, $page, $this->property('load_thumbnails'), $this->property('load_gallery'), $this->property('load_inventories')); } catch (ModelNotFoundException $e) { return $this->controller->run('404'); } }