You are here

public function CountryTest::testAllDisabled in Ubercart 8.4

Test functionality with all countries disabled.

File

uc_country/tests/src/Functional/CountryTest.php, line 91

Class

CountryTest
Import, edit, and remove countries and their settings.

Namespace

Drupal\Tests\uc_country\Functional

Code

public function testAllDisabled() {

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer countries',
    'administer store',
    'access administration pages',
  ]));

  // Disable all countries.
  $manager = \Drupal::service('country_manager');
  $countries = $manager
    ->getEnabledList();
  foreach (array_keys($countries) as $code) {
    $manager
      ->getCountry($code)
      ->disable()
      ->save();
  }

  // Verify that an error is shown.
  $this
    ->drupalGet('admin/store');
  $assert
    ->pageTextContains('No countries are enabled.');

  // Verify that the country fields are hidden.
  $this
    ->drupalGet('admin/store/config/store');
  $assert
    ->pageTextNotContains('State/Province');
  $assert
    ->pageTextNotContains('Country');
}