/** * Store a newly created resource in storage. * * @param NodeTypeRepository $nodeTypeRepository * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(NodeTypeRepository $nodeTypeRepository, Request $request) { $this->authorize('EDIT_NODETYPES'); $this->validateCreateForm($request); $nodeType = $nodeTypeRepository->create($request->all()); $this->notify('nodetypes.created'); return redirect()->route('reactor.nodetypes.edit', $nodeType->getKey()); }
/** @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()); }