/** * @test */ public function remove_will_remove_an_existing_segment() { $client = $this->prophesize(Auth::class); $repository = new SegmentRepository($client->reveal()); $id = '12346'; $responseBody = json_encode(['response' => ['status' => 'OK']]); $fakeResponse = $this->prophesize(Response::class); $stream = $this->prophesize(Stream::class); $stream->getContents()->willReturn($responseBody); $stream->rewind()->willReturn(null)->shouldBeCalled(); $fakeResponse->getBody()->willReturn($stream->reveal()); $client->request('DELETE', Argument::containingString($id))->willReturn($fakeResponse)->shouldBeCalled(); $repositoryResponse = $repository->remove('member_id', $id); $this->assertTrue($repositoryResponse->isSuccessful()); }
/** * @param $id * * @return RepositoryResponse */ public function remove($id) { return $this->segmentRepository->remove($this->memberId, $id); }