/** * Remove the specified resources from storage. * * @param NodeTypeRepository $nodeTypeRepository * @param Request $request * @return \Illuminate\Http\Response */ public function bulkDestroy(NodeTypeRepository $nodeTypeRepository, Request $request) { $this->authorize('EDIT_NODETYPES'); $ids = json_decode($request->input('_bulkSelected', '[]')); foreach ($ids as $id) { $nodeTypeRepository->destroy($id); } $this->notify('nodetypes.destroyed'); return redirect()->route('reactor.nodetypes.index'); }
/** @test */ function it_destroys_a_node_type() { $builderService = $this->prophesize('Nuclear\\Hierarchy\\Contract\\Builders\\BuilderServiceContract'); // This part is for the sake of setting the test up $builderService->buildTable('project', Argument::type('int'))->shouldBeCalled(); $repository = new NodeTypeRepository($builderService->reveal()); $nodeType = $repository->create(['name' => 'project', 'label' => 'Project']); $this->assertEquals(1, NodeType::count()); $builderService->destroyTable('project', [], $nodeType->getKey())->shouldBeCalled(); $repository->destroy($nodeType->getKey()); $this->assertEquals(0, NodeType::count()); }