You are here

public function ZoneTerritoryElementTest::testZoneTerritory in Address 8

Tests the zone territory form element.

File

tests/src/FunctionalJavascript/ZoneTerritoryElementTest.php, line 34

Class

ZoneTerritoryElementTest
Tests the address_zone_territory form element.

Namespace

Drupal\Tests\address\FunctionalJavascript

Code

public function testZoneTerritory() {
  $this
    ->drupalGet('/address_test/zone_territory_test_form');
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('territory[country_code]', 'US');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->fieldExists('territory[administrative_area]');
  $this
    ->assertSession()
    ->fieldExists('territory[limit_by_postal_code]');
  $this
    ->getSession()
    ->getPage()
    ->checkField('territory[limit_by_postal_code]');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->fieldExists('territory[included_postal_codes]');
  $this
    ->assertSession()
    ->fieldExists('territory[excluded_postal_codes]');
  $this
    ->submitForm([
    'territory[administrative_area]' => 'SC',
    'territory[included_postal_codes]' => '29601',
    'territory[excluded_postal_codes]' => '29602',
  ], 'Submit');
  $this
    ->assertSession()
    ->pageTextContains('Submitted: US / SC / 29601 / 29602.');
}