Exemple #1
0
 /**
  * @dataProvider testIsCouponActiveProvider
  * @group coupon
  */
 public function testIsCouponActive($from, $until, $expected)
 {
     $coupon = new Coupon();
     $coupon->setValidFrom($from);
     $coupon->setValidUntil($until);
     $this->assertInternalType('boolean', $coupon->isActive());
     $this->assertEquals($expected, $coupon->isActive());
 }
Exemple #2
0
 public function import(array $array)
 {
     foreach ($array as $p) {
         $coupon = new Coupon();
         $coupon->setCode($p['code']);
         $coupon->setType($p['type']);
         if (isset($p['products']) && !empty($p['products'])) {
             $coupon->setProducts($p['products']);
         }
         if (isset($p['config']) && !empty($p['config'])) {
             $coupon->setConfig($p['config']);
         }
         if (isset($p['valid_from']) && !empty($p['valid_from'])) {
             $coupon->setValidFrom($p['valid_from']);
         }
         if (isset($p['valid_until']) && !empty($p['valid_until'])) {
             $coupon->setValidUntil($p['valid_until']);
         }
         $this->addCoupon($coupon);
     }
 }