/** * @test */ public function update_will_edit_an_existing_segment() { $repository = $this->getSegmentRepository(); $segment = new Segment(); $segment->setName('Test segment ' . uniqid()); $segment->setCategory('a-test-category'); $segment->setDescription('a test description 123456'); $segment->setCode(rand(0, 999) * rand(0, 999)); $segment->setPrice(10.11); $segment->setMemberId(getenv('MEMBER_ID')); $segment->setActive(true); $repositoryResponse = $repository->add($segment); $this->assertTrue($repositoryResponse->isSuccessful(), $repositoryResponse->getError()->getError()); $segment->setPrice(12.11); $repositoryResponse = $repository->update($segment); $this->assertTrue($repositoryResponse->isSuccessful(), $repositoryResponse->getError()->getError()); $this->assertEquals(12.11, $segment->getPrice()); }
/** * @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()); }