/**
  * @test
  */
 public function add_will_create_a_new_segment_and_return_a_repository_response()
 {
     $client = $this->prophesize(Auth::class);
     $repository = new SegmentBillingRepository($client->reveal());
     $segment = new SegmentBilling();
     $segment->setIsPublic(true);
     $segment->setDataCategoryId(1001);
     $segment->setDataProviderId(getenv('DATA_PROVIDER_ID'));
     $segment->setActive(true);
     $fakeResponse = $this->getFakeResponse($this->getSingleBillingSegment());
     $payload = ['segment-billing-category' => $segment->toArray()];
     $client->request('POST', Argument::any(), ['body' => json_encode($payload)])->willReturn($fakeResponse)->shouldBeCalled();
     $repositoryResponse = $repository->add($segment);
     $this->assertTrue($repositoryResponse->isSuccessful());
     $this->assertEquals(123, $segment->getId());
 }
 /**
  * @test
  */
 public function delete_will_remove_a_segment()
 {
     $repositorySegment = $this->getSegmentRepository();
     $segment = new Segment();
     $segment->setName('Test segment' . uniqid());
     $segment->setCategory('Test category' . uniqid());
     $segment->setMemberId(getenv('MEMBER_ID'));
     $segment->setActive(true);
     $repositoryResponseSegment = $repositorySegment->add($segment);
     $this->assertTrue($repositoryResponseSegment->isSuccessful(), $repositoryResponseSegment->getError()->getError());
     $this->assertNotNull($segment->getId());
     $repository = $this->getSegmentBillingRepository();
     $segmentBilling = new SegmentBilling();
     $segmentBilling->setMemberId(getenv('MEMBER_ID'));
     $segmentBilling->setActive(true);
     $segmentBilling->setDataCategoryId(getenv('DATA_CATEGORY_ID'));
     $segmentBilling->setDataProviderId(getenv('DATA_PROVIDER_ID'));
     $segmentBilling->setSegmentId($segment->getId());
     $segmentBilling->setIsPublic(true);
     $repositoryResponse = $repository->add($segmentBilling);
     $this->assertTrue($repositoryResponse->isSuccessful(), $repositoryResponse->getError()->getError());
     $repositoryResponse = $repository->remove($segmentBilling->getMemberId(), $segmentBilling->getId());
     $this->assertTrue($repositoryResponse->isSuccessful(), $repositoryResponse->getError()->getError());
 }