You are here

public function NumberPatternTest::testAdd in Commerce Core 8.2

Tests adding a number pattern.

File

modules/number_pattern/tests/src/FunctionalJavascript/NumberPatternTest.php, line 38

Class

NumberPatternTest
Tests the number pattern admin UI.

Namespace

Drupal\Tests\commerce_number_pattern\FunctionalJavascript

Code

public function testAdd() {
  $this
    ->drupalGet('admin/commerce/config/number-patterns/add');
  $page = $this
    ->getSession()
    ->getPage();

  // Confirm that the target entity type field is hidden when there's only
  // one option.
  $this
    ->assertSession()
    ->fieldNotExists('targetEntityType');
  $page
    ->fillField('label', 'Foo');
  $page
    ->selectFieldOption('plugin', 'monthly');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->submitForm([], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Foo number pattern.');
  $number_pattern = NumberPattern::load('foo');
  $this
    ->assertNotEmpty($number_pattern);
  $this
    ->assertEquals('Foo', $number_pattern
    ->label());
  $this
    ->assertEquals('entity_test_with_store', $number_pattern
    ->getTargetEntityTypeId());
  $this
    ->assertEquals('monthly', $number_pattern
    ->getPluginId());
}