You are here

public function PromotionTest::testAdminPromotions in Commerce Core 8.2

Tests viewing the admin/commerce/promotions page.

File

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

Class

PromotionTest
Tests the admin UI for promotions.

Namespace

Drupal\Tests\commerce_promotion\FunctionalJavascript

Code

public function testAdminPromotions() {

  /** @var \Drupal\commerce_promotion\Entity\PromotionInterface $promotion */
  $promotion = $this
    ->createEntity('commerce_promotion', [
    'name' => $this
      ->randomMachineName(8),
  ]);
  $this
    ->drupalGet('admin/commerce/promotions');
  $this
    ->assertNotEmpty($this
    ->getSession()
    ->getPage()
    ->hasLink('Add promotion'));
  $this
    ->assertSession()
    ->pageTextNotContains('There are no enabled promotions yet.');
  $this
    ->assertSession()
    ->pageTextContains('There are no disabled promotions.');
  $this
    ->assertTrue($this
    ->getSession()
    ->getPage()
    ->hasLink('Disable'));
  $this
    ->assertFalse($this
    ->getSession()
    ->getPage()
    ->hasLink('Enable'));
  $this
    ->assertTrue($this
    ->getSession()
    ->getPage()
    ->hasLink('Delete'));
  $this
    ->drupalGet($promotion
    ->toUrl('disable-form'));
  $this
    ->submitForm([], t('Disable'));
  $this
    ->assertSession()
    ->pageTextContains('There are no enabled promotions yet.');
  $this
    ->assertSession()
    ->pageTextNotContains('There are no disabled promotions.');
  $this
    ->assertTrue($this
    ->getSession()
    ->getPage()
    ->hasLink('Enable'));
}