You are here

public function CustomerProfileTest::testCountries in Commerce Core 8.2

Tests the country handling.

File

modules/order/tests/src/FunctionalJavascript/CustomerProfileTest.php, line 90

Class

CustomerProfileTest
Tests the customer_profile inline form.

Namespace

Drupal\Tests\commerce_order\FunctionalJavascript

Code

public function testCountries() {

  // Confirm that the country list has been restricted to available countries.
  $this
    ->drupalGet('/commerce_order_test/customer_profile_test_form');
  $options = $this
    ->xpath('//select[@name="profile[address][0][address][country_code]"]/option');
  $this
    ->assertCount(4, $options);
  $this
    ->assertEquals('FR', $options[0]
    ->getValue());
  $this
    ->assertEquals('HU', $options[1]
    ->getValue());
  $this
    ->assertEquals('RS', $options[2]
    ->getValue());
  $this
    ->assertEquals('US', $options[3]
    ->getValue());

  // Confirm that the store default is selected when available.
  $this
    ->assertNotEmpty($options[2]
    ->getAttribute('selected'));

  // Confirm that it is possible to change the country and submit the form.
  $this
    ->getSession()
    ->getPage()
    ->fillField('profile[address][0][address][country_code]', 'FR');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->submitForm([
    'profile[address][0][address][given_name]' => 'Leon',
    'profile[address][0][address][family_name]' => 'Blum',
    'profile[address][0][address][address_line1]' => '38 Rue du Sentier',
    'profile[address][0][address][postal_code]' => '75002',
    'profile[address][0][address][locality]' => 'Paris',
  ], 'Submit');
  $this
    ->assertSession()
    ->pageTextContains('The street is "38 Rue du Sentier" and the country code is FR.');
}