You are here

class CountriesBaseImportUnitTest in Countries 8

Same name and namespace in other branches
  1. 7.2 tests/countries.test \CountriesBaseImportUnitTest

Hierarchy

Expanded class hierarchy of CountriesBaseImportUnitTest

File

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

View source
class CountriesBaseImportUnitTest extends CountriesBaseSetupTest {
  public static function getInfo() {
    return array(
      'name' => 'Country imports from CSV file',
      'description' => 'Test the import functions.',
      'group' => 'Countries',
    );
  }
  function setUp() {
    parent::setUp(array(
      'countries',
    ));
    $this
      ->drupalLogin($this->admin_user);
  }

  /**
   * The list is updated on install.
   */
  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');
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CountriesBaseImportUnitTest::getInfo public static function
CountriesBaseImportUnitTest::setUp function Overrides CountriesBaseSetupTest::setUp
CountriesBaseImportUnitTest::testCountriesCoreListingInstallImport function The list is updated on install.
CountriesBaseSetupTest::assertCountryListed function
CountriesBaseSetupTest::assertListingLink function
CountriesBaseSetupTest::assertNoOptionPresent function
CountriesBaseSetupTest::assertOptionPresent function
CountriesBaseSetupTest::getDisabledCountries function Provides a sample group of countries defined by core that match the ISO Standards.
CountriesBaseSetupTest::getNewCountries function These countries are not part of core.
CountriesBaseSetupTest::getNonStandardCountries function These are the invalid strings in core.
CountriesBaseSetupTest::getNonStandardCountriesCorrected function The valid list if ISO strings
CountriesBaseSetupTest::getUnchangedCountries function Provides a sample group of countries defined by core that match the ISO Standards.