You are here

public function CountrySortTest::testSortCountryName in Address 8

Test sorting by country name.

File

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

Class

CountrySortTest
Tests sorting Views by country.

Namespace

Drupal\Tests\address\Functional\Views

Code

public function testSortCountryName() {

  // Force the view to sort by name.
  $view = Views::getView('address_test_sort_country');
  $sorts = $view
    ->getDisplay()
    ->getOption('sorts');
  $sorts['field_address_test_country_code']['sort_by'] = 'name';
  $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-HR');
  $this
    ->assertSession()
    ->pageTextContains('3-FR');
  $this
    ->assertSession()
    ->pageTextContains('4-DE');
  $this
    ->assertSession()
    ->pageTextContains('5-VI');
  $this
    ->assertSession()
    ->pageTextContains('6-US');
}