public function CouponTest::testCoupon in Commerce Core 8.2
@covers ::getPromotion @covers ::getPromotionId @covers ::getCode @covers ::setCode @covers ::getCreatedTime @covers ::setCreatedTime @covers ::getUsageLimit @covers ::setUsageLimit @covers ::getCustomerUsageLimit @covers ::setCustomerUsageLimit @covers ::isEnabled @covers ::setEnabled
File
- modules/
promotion/ tests/ src/ Kernel/ Entity/ CouponTest.php, line 56
Class
- CouponTest
- Tests the Coupon entity.
Namespace
Drupal\Tests\commerce_promotion\Kernel\EntityCode
public function testCoupon() {
$promotion = Promotion::create([
'status' => FALSE,
]);
$promotion
->save();
$promotion = $this
->reloadEntity($promotion);
$coupon = Coupon::create([
'status' => FALSE,
'promotion_id' => $promotion
->id(),
]);
$this
->assertEquals($promotion, $coupon
->getPromotion());
$this
->assertEquals($promotion
->id(), $coupon
->getPromotionId());
$coupon
->setCode('test_code');
$this
->assertEquals('test_code', $coupon
->getCode());
$coupon
->setCreatedTime(635879700);
$this
->assertEquals(635879700, $coupon
->getCreatedTime());
$coupon
->setUsageLimit(10);
$this
->assertEquals(10, $coupon
->getUsageLimit());
$coupon
->setCustomerUsageLimit(1);
$this
->assertEquals(1, $coupon
->getCustomerUsageLimit());
$coupon
->setEnabled(TRUE);
$this
->assertEquals(TRUE, $coupon
->isEnabled());
}