/** * @test */ public function add_will_create_a_new_segment_and_return_a_repository_response() { $client = $this->prophesize(Auth::class); $repository = new SegmentRepository($client->reveal()); $segment = new Segment(); $segment->setName('Test segment'); $fakeResponse = $this->getFakeResponse($this->getSingleSegment()); $payload = ['segment' => $segment->toArray()]; $client->request('POST', Argument::any(), ['body' => json_encode($payload)])->willReturn($fakeResponse)->shouldBeCalled(); $repositoryResponse = $repository->add($segment); $this->assertTrue($repositoryResponse->isSuccessful()); $this->assertEquals(5012, $segment->getId()); }
/** * @param Segment $segment * * @return RepositoryResponse * @throws \Exception */ public function add(Segment $segment) { return $this->segmentRepository->add($segment); }