You are here

function UbercartCountryTestCase::testCountries in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_store/tests/uc_store.test \UbercartCountryTestCase::testCountries()

File

uc_store/uc_store.test, line 203
Test functionality provided by uc_store.

Class

UbercartCountryTestCase
Test the country import and update functions.

Code

function testCountries() {
  $import_file = 'belgium_56_3.cif';
  $country_name = 'Belgium';
  $country_code = 'BEL';
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/store/settings/countries/edit');
  $this
    ->assertRaw('<option value="' . $import_file . '">' . $import_file . '</option>', t('Ensure country file is not imported yet.'));
  $edit = array(
    'import_file[]' => array(
      $import_file => $import_file,
    ),
  );
  $this
    ->drupalPost('admin/store/settings/countries/edit', $edit, t('Import'));
  $this
    ->assertText(t('Country file @file imported.', array(
    '@file' => $import_file,
  )), t('Country was imported successfully.'));
  $this
    ->assertText($country_code, t('Country appears in the imported countries table.'));
  $this
    ->assertNoRaw('<option value="' . $import_file . '">' . $import_file . '</option>', t('Country does not appear in list of files to be imported.'));
  $this
    ->clickLink(t('disable'));
  $this
    ->assertText(t('@name disabled.', array(
    '@name' => $country_name,
  )), t('Country was disabled.'));
  $this
    ->clickLink(t('enable'));
  $this
    ->assertText(t('@name enabled.', array(
    '@name' => $country_name,
  )), t('Country was enabled.'));
  $this
    ->clickLink(t('remove'));
  $this
    ->assertText(t('Are you sure you want to remove @name from the system?', array(
    '@name' => $country_name,
  )), t('Confirm form is displayed.'));
  $this
    ->drupalPost('admin/store/settings/countries/56/remove', array(), t('Remove'));
  $this
    ->assertText(t('@name removed.', array(
    '@name' => $country_name,
  )), t('Country removed.'));
  $this
    ->assertRaw('<option value="' . $import_file . '">' . $import_file . '</option>', t('Ensure country file is not imported yet.'));
  $this
    ->assertNoText($country_code, t('Country does not appear in imported countries table.'));
}