You are here

public function PromotionTest::testDisablePromotion in Commerce Core 8.2

Tests disabling a promotion.

File

modules/promotion/tests/src/FunctionalJavascript/PromotionTest.php, line 422

Class

PromotionTest
Tests the admin UI for promotions.

Namespace

Drupal\Tests\commerce_promotion\FunctionalJavascript

Code

public function testDisablePromotion() {

  /** @var \Drupal\commerce_promotion\Entity\PromotionInterface $promotion */
  $promotion = $this
    ->createEntity('commerce_promotion', [
    'name' => $this
      ->randomMachineName(8),
  ]);
  $this
    ->assertTrue($promotion
    ->isEnabled());
  $this
    ->drupalGet($promotion
    ->toUrl('disable-form'));
  $this
    ->assertSession()
    ->pageTextContains(t('Are you sure you want to disable the promotion @label?', [
    '@label' => $promotion
      ->label(),
  ]));
  $this
    ->submitForm([], t('Disable'));
  $promotion = $this
    ->reloadEntity($promotion);
  $this
    ->assertFalse($promotion
    ->isEnabled());
}