Пример #1
0
 /**
  * @expectedException \Trismegiste\SocialBundle\Ticket\InvalidCouponException
  */
 public function testCreateTicketFromOverusedCoupon()
 {
     $coupon = new Coupon();
     $coupon->expiredAt = new \DateTime('tomorrow');
     $coupon->incUse();
     $this->assertFalse($coupon->isValid());
     $this->sut->createTicketFromCoupon($coupon);
 }
Пример #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 testValidityWithCounter()
 {
     $this->assertTrue($this->sut->isValid());
     $this->sut->incUse();
     $this->assertFalse($this->sut->isValid());
 }