public function CouponTest::testDeleteCoupon in Commerce Core 8.2
Tests deleting a coupon.
File
- modules/
promotion/ tests/ src/ Functional/ CouponTest.php, line 116
Class
- CouponTest
- Tests the admin UI for coupons.
Namespace
Drupal\Tests\commerce_promotion\FunctionalCode
public function testDeleteCoupon() {
$coupon = $this
->createEntity('commerce_promotion_coupon', [
'promotion_id' => $this->promotion
->id(),
'code' => $this
->randomMachineName(8),
'status' => FALSE,
'usage_limit' => 0,
'usage_limit_customer' => 0,
]);
$this
->drupalGet($coupon
->toUrl('delete-form'));
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('This action cannot be undone.');
$this
->submitForm([], t('Delete'));
$this->container
->get('entity_type.manager')
->getStorage('commerce_promotion_coupon')
->resetCache([
$coupon
->id(),
]);
$coupon_exists = (bool) Coupon::load($coupon
->id());
$this
->assertFalse($coupon_exists);
}