Пример #1
0
 public function testGetter()
 {
     $this->assertEquals('toto', $this->sut->getHashKey());
     $this->assertEquals(5, $this->sut->getDurationValue());
     $this->assertEquals('+5 day', $this->sut->getDurationOffset());
     $this->assertEquals('coupon toto', $this->sut->getTitle());
 }
Пример #2
0
 /**
  * Ticket factory
  * WARNING: edge effect on Coupon
  *
  * @param Coupon $coupon (edge effect on usedCounter)
  *
  * @throws InvalidCouponException
  */
 public function createTicketFromCoupon(Coupon $coupon)
 {
     if (!$coupon->isValid()) {
         throw new InvalidCouponException("The coupon '{$coupon->getHashKey()}' has expired or has been used too many times");
     }
     $ticket = new Ticket($coupon);
     $coupon->incUse();
     return $ticket;
 }
Пример #3
0
 public function getValidInputs()
 {
     $obj = new Coupon();
     $obj->setDurationValue(5);
     $obj->hashKey = 'AZERTY';
     $obj->maximumUse = 50;
     $obj->expiredAt = new DateTime('2015-05-05');
     return [[['durationValue' => 5, 'hashKey' => 'AZERTY', 'maximumUse' => 50, 'expiredAt' => ['year' => 2015, 'month' => 5, 'day' => 5]], $obj]];
 }
Пример #4
0
 public function testDeleteCoupon()
 {
     $pk = '5599f782e3f434f616787edc';
     $coupon = new Coupon();
     $coupon->setId(new \MongoId($pk));
     $this->repository->expects($this->once())->method('findByPk')->with($pk)->willReturn($coupon);
     $this->repository->expects($this->once())->method('delete')->with($pk);
     $this->sut->deleteCoupon($pk);
 }