/** * @test create */ public function testCreateEndereco() { $endereco = $this->fakeEnderecoData(); $createdEndereco = $this->enderecoRepo->create($endereco); $createdEndereco = $createdEndereco->toArray(); $this->assertArrayHasKey('id', $createdEndereco); $this->assertNotNull($createdEndereco['id'], 'Created Endereco must have id specified'); $this->assertNotNull(Endereco::find($createdEndereco['id']), 'Endereco with given id must be in DB'); $this->assertModelData($endereco, $createdEndereco); }
/** * @param CreateEnderecoAPIRequest $request * @return Response * * @SWG\Post( * path="/enderecos", * summary="Store a newly created Endereco in storage", * tags={"Endereco"}, * description="Store Endereco", * produces={"application/json"}, * @SWG\Parameter( * name="body", * in="body", * description="Endereco that should be stored", * required=false, * @SWG\Schema(ref="#/definitions/Endereco") * ), * @SWG\Response( * response=200, * description="successful operation", * @SWG\Schema( * type="object", * @SWG\Property( * property="success", * type="boolean" * ), * @SWG\Property( * property="data", * ref="#/definitions/Endereco" * ), * @SWG\Property( * property="message", * type="string" * ) * ) * ) * ) */ public function store(CreateEnderecoAPIRequest $request) { $input = $request->all(); $enderecos = $this->enderecoRepository->create($input); return $this->sendResponse($enderecos->toArray(), 'Endereco saved successfully'); }