/** * @expectedException LaravelItalia\Exceptions\NotFoundException */ public function testCanFindByIdThrowsException() { $this->repository->findById(999); }
/** * Cancella la categoria il cui id è $categoryId. * * @param CategoryRepository $categoryRepository * @param $categoryId * @return \Illuminate\Http\RedirectResponse */ public function getDelete(CategoryRepository $categoryRepository, $categoryId) { try { /* @var $category Category */ $category = $categoryRepository->findById($categoryId); } catch (NotFoundException $e) { return redirect('admin/categories')->with('error_message', 'La categoria cercata non esiste o non è più disponibile.'); } try { $categoryRepository->delete($category); } catch (NotDeletedException $e) { return redirect('admin/categories')->with('error_message', 'Impossibile elminare la categoria scelta. Riprovare.'); } return redirect('admin/categories')->with('success_message', 'Categoria eliminata correttamente.'); }