public function testCanDelete() { $category = $this->saveTestCategory(); $this->repository->delete($category); $this->dontSeeInDatabase('categories', ['name' => 'Test Category', 'slug' => 'test-category']); }
/** * 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.'); }