Пример #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;
 }