You are here

function CountriesCRUDUIUnitTest::testISO2Conflict in Countries 7.2

Same name and namespace in other branches
  1. 8 tests/countries.test \CountriesCRUDUIUnitTest::testISO2Conflict()

Special case where the ISO matches an existing ISO code.

If the same country is added twice, there are multiple errors generated due to the ISO alpha-2 conflict.

File

tests/countries.test, line 918
Tests for countries.module.

Class

CountriesCRUDUIUnitTest
Test the node_load_multiple() function.

Code

function testISO2Conflict() {
  $oz = country_load('au');
  $edit = array();
  foreach (countries_core_properties() as $key => $label) {
    $edit[$key] = $oz->{$key};
  }
  $this
    ->drupalPost('admin/config/regional/countries/add', $edit, t('Save'));
  $this
    ->assertNoRaw(t('Added country %country.', array(
    '%country' => $oz->name,
  )), 'New country was not added (iso2 validation)');
  $this
    ->assertRaw(t('Another country was found with this ISO alpha-2 code; !link', array(
    '!link' => l(countries_t($oz), 'admin/config/regional/countries/' . $oz->iso2),
  )), 'New country was not added (iso2 validation)');
  $nz = country_load('nz');
  $edit = array();
  foreach (countries_core_properties() as $key => $label) {
    $edit[$key] = $nz->{$key};
  }
  $edit['iso2'] = 'au';
  $this
    ->drupalPost('admin/config/regional/countries/add', $edit, t('Save'));
  $this
    ->assertRaw(t('Another country was found with this ISO alpha-2 code; !link', array(
    '!link' => l(countries_t($oz), 'admin/config/regional/countries/' . $oz->iso2),
  )), 'New country was not added (iso2 validation)');
}