function CountriesBaseImportUnitTest::testCountriesCoreListingInstallImport in Countries 8
The list is updated on install.
File
- tests/
countries.test, line 234 - Tests for countries.module.
Class
Code
function testCountriesCoreListingInstallImport() {
// Parse and compare the default listings as returned by Drupal.
$unchanged_countries = $this
->getUnchangedCountries();
// Stale core countries
$changed_countries_originals = $this
->getNonStandardCountries();
// Updated core countries to the iso standards.
$changed_countries = $this
->getNonStandardCountriesCorrected();
// New countries.
$new_countries = $this
->getNewCountries();
// Check that things are still valid tests.
$core_tests = array_merge($unchanged_countries, $changed_countries_originals);
$countries = _country_get_predefined_list();
foreach ($core_tests as $iso2 => $name) {
if ($this
->assertNotNull($countries[$iso2], 'Core country ' . $iso2 . ' - ' . $name . ' defined')) {
$this
->assertEqual($name, $countries[$iso2], 'Core country name ' . $name . ' unchanged ' . $countries[$iso2]);
}
}
foreach ($new_countries as $iso2 => $name) {
$this
->assertTrue(empty($countries[$iso2]), 'Countries new country ' . $iso2 . ' - ' . $name . ' not included in core');
}
// Now test that our updates are appearing.
$countries = country_get_list();
foreach ($unchanged_countries as $iso2 => $name) {
if ($this
->assertNotNull($countries[$iso2], 'Testing unmodified country ' . $iso2 . ' - ' . $name . ' exists')) {
$this
->assertEqual($name, $countries[$iso2], 'Testing unmodified country ' . $name . ' matches core drupal');
}
}
// Installation now imports the changes directly.
foreach ($changed_countries as $iso2 => $name) {
if ($this
->assertNotNull($countries[$iso2], 'Testing updated country ' . $iso2 . ' - ' . $name . ' exists')) {
$this
->assertEqual($name, $countries[$iso2], 'Testing updated country ' . $name . ' is was overriden by default to ' . $countries[$iso2]);
}
}
foreach ($new_countries as $iso2 => $name) {
if ($this
->assertTrue(!empty($countries[$iso2]), 'Testing new country ' . $iso2 . ' - ' . $name . ' exists')) {
$this
->assertEqual($name, $countries[$iso2], 'Testing new country ' . $name . ' matches new listing');
}
}
}