/**
  * @test
  */
 public function update_will_edit_an_existing_segment()
 {
     $client = $this->prophesize(Auth::class);
     $repository = new SegmentRepository($client->reveal());
     $segment = new Segment();
     $segment->setName('Test segment');
     $segment->setId(123456);
     $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());
     $payload = ['segment' => $segment->toArray()];
     $client->request('PUT', Argument::any(), ['body' => json_encode($payload)])->willReturn($fakeResponse)->shouldBeCalled();
     $repositoryResponse = $repository->update($segment);
     $this->assertTrue($repositoryResponse->isSuccessful());
 }
Ejemplo n.º 2
0
 /**
  * @param Segment $segment
  *
  * @return RepositoryResponse
  * @throws \Exception
  */
 public function update(Segment $segment)
 {
     return $this->segmentRepository->update($segment);
 }