You are here

public function PromotionTest::testEnablePromotion in Commerce Core 8.2

Tests enabling a promotion.

File

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

Class

PromotionTest
Tests the admin UI for promotions.

Namespace

Drupal\Tests\commerce_promotion\FunctionalJavascript

Code

public function testEnablePromotion() {

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