You are here

public function CountrySortTest::testSortCountryCode in Address 8

Test sorting by country code.

File

tests/src/Functional/Views/CountrySortTest.php, line 86

Class

CountrySortTest
Tests sorting Views by country.

Namespace

Drupal\Tests\address\Functional\Views

Code

public function testSortCountryCode() {

  // Force the view to sort by code.
  $view = Views::getView('address_test_sort_country');
  $sorts = $view
    ->getDisplay()
    ->getOption('sorts');
  $sorts['field_address_test_country_code']['sort_by'] = 'code';
  $view
    ->getDisplay()
    ->overrideOption('sorts', $sorts);
  $view
    ->save();
  $this
    ->drupalGet('address-test/views/sort-country');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('1-AT');
  $this
    ->assertSession()
    ->pageTextContains('2-DE');
  $this
    ->assertSession()
    ->pageTextContains('3-FR');
  $this
    ->assertSession()
    ->pageTextContains('4-HR');
  $this
    ->assertSession()
    ->pageTextContains('5-US');
  $this
    ->assertSession()
    ->pageTextContains('6-VI');
}