You are here

class CountriesApiTest in Country codes API 5

Hierarchy

Expanded class hierarchy of CountriesApiTest

File

tests/countries_api.test, line 11

View source
class CountriesApiTest extends DrupalTestCase {
  function get_info() {
    return array(
      'name' => t('Countries API tests'),
      'desc' => t('Tests countries api functions'),
      'group' => t('countries_api tests'),
    );
  }

  /**
   * Function to test countries_api_get_formats() results
   **/
  function test_countries_api_get_formats() {
    $formats = countries_api_get_formats();
    $this
      ->assertNotNull($formats, 'Checking countries API format results. %s');
  }

  /**
   * Function to validate format (and presence of) countries from countries_api_get_list()
   **/
  function test_countries_api_get_list() {
    $countries = countries_api_get_list();
    $this
      ->assertTrue(is_array($countries), 'Checking countries api list. %s');
  }

  /**
   * Function to validate length of countries list is greater than 0
   **/
  function test_count_countries_api_get_list() {
    $countries = countries_api_get_list();
    $this
      ->assertNotEqual(count($countries), 0, 'Checking size of countries api. %s');
  }

  /**
   * Function to test _countries_api_iso_get_country returns a value
   **/
  function test_results_countries_api_iso_get_country() {
    $value = VALID_ISO2;
    $format = VALID_FORMAT;
    $country = _countries_api_iso_get_country($value, $format);
    $this
      ->assertTrue($country, 'Testing countries_api_iso_get_country return format. %s');
  }

  /**
   * Function to test invalid format passed to _countries_api_iso_get_country
   **/
  function test_invalidformat__countries_api_iso_get_country() {
    $value = VALID_ISO2;
    $format = INVALID_FORMAT;
    $country = _countries_api_iso_get_country($value, $format);
    $this
      ->assertFalse($country, 'Testing countries_api_iso_get_country format validation. %s');
  }

  /**
   * Function to test countries_api_iso3_get_iso2() results
   **/
  function test_countries_api_iso3_get_iso2() {
    $code = VALID_ISO3;
    $iso2 = countries_api_iso3_get_iso2($code);
    $this
      ->assertNotEqual($iso2, false, 'Test countries_api_iso3_get_iso2 results. %s');
  }

  /**
   * Function to test countries_api_iso2_get_iso3() results
   **/
  function test_countries_api_iso2_get_iso3() {
    $code = VALID_ISO2;
    $iso3 = countries_api_iso2_get_iso3($code);
    $this
      ->assertNotEqual($iso3, false, 'Test countries_api_iso2_get_iso3 results. %s');
  }

  /**
   * Function to test results of countries_api_iso3_get_name()
   **/
  function test_countries_api_iso3_get_name() {
    $code = VALID_ISO3;
    $country_name = countries_api_iso3_get_name($code);
    $this
      ->assertNotNull($country_name, 'Test countries_api_iso3_get_name results. %s');
  }

  /**
   * Function to test results of countries_api_iso3_get_name()
   **/
  function test_nullcountries_api_iso3_get_name() {
    $code = INVALID_ISO3;
    $country_name = countries_api_iso3_get_name($code);
    $this
      ->assertNull($country_name, 'Tests countries_api_iso3_get_name with an incorrect code. %s');
  }

  /**
   * Function to test results of countries_api_iso2_get_name()
   **/
  function test_countries_api_iso2_get_name() {
    $code = VALID_ISO2;
    $country_name = countries_api_iso2_get_name($code);
    $this
      ->assertNotNull($country_name, 'Test countries_api_iso2_get_name results. %s');
  }

  /**
   * Function to test results of countries_api_iso2_get_name()
   **/
  function test_nullcountries_api_iso2_get_name() {
    $code = INVALID_ISO3;
    $country_name = countries_api_iso2_get_name($code);
    $this
      ->assertNull($country_name, 'Tests countries_api_iso2_get_name with an incorrect code. %s');
  }

  /**
   * Function to test countries_api_get_name() results
   **/
  function test_countries_api_get_name() {
    $name = VALID_ISO2;
    $country_name = countries_api_get_name($name);
    $this
      ->assertNotNull($country_name, 'Test test_countries_api_get_name results. %s');
  }

  /**
   * Function to test countries_api_get_name() results with invalid name
   **/
  function test_invalid_countries_api_get_name() {
    $name = INVALID_ISO2;
    $country_name = countries_api_get_name($name);
    $this
      ->assertNull($country_name, 'Test test_countries_api_get_name results. %s');
  }

  /**
   * Function to test countries_api_get_array() results
   **/
  function test_countries_api_get_array() {
    $countries = countries_api_get_array();
    $this
      ->assertNotEqual($countries, false, 'Test results of countries_api_get_array.');
  }

  /**
   * Function to test countries_api_get_options_array results
   **/
  function test_countries_api_get_options_array() {
    $countries = countries_api_get_options_array();
    $this
      ->assertNotNull($countries, 'Test countries_api_get_options_array.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CountriesApiTest::get_info function
CountriesApiTest::test_countries_api_get_array function Function to test countries_api_get_array() results
CountriesApiTest::test_countries_api_get_formats function Function to test countries_api_get_formats() results
CountriesApiTest::test_countries_api_get_list function Function to validate format (and presence of) countries from countries_api_get_list()
CountriesApiTest::test_countries_api_get_name function Function to test countries_api_get_name() results
CountriesApiTest::test_countries_api_get_options_array function Function to test countries_api_get_options_array results
CountriesApiTest::test_countries_api_iso2_get_iso3 function Function to test countries_api_iso2_get_iso3() results
CountriesApiTest::test_countries_api_iso2_get_name function Function to test results of countries_api_iso2_get_name()
CountriesApiTest::test_countries_api_iso3_get_iso2 function Function to test countries_api_iso3_get_iso2() results
CountriesApiTest::test_countries_api_iso3_get_name function Function to test results of countries_api_iso3_get_name()
CountriesApiTest::test_count_countries_api_get_list function Function to validate length of countries list is greater than 0
CountriesApiTest::test_invalidformat__countries_api_iso_get_country function Function to test invalid format passed to _countries_api_iso_get_country
CountriesApiTest::test_invalid_countries_api_get_name function Function to test countries_api_get_name() results with invalid name
CountriesApiTest::test_nullcountries_api_iso2_get_name function Function to test results of countries_api_iso2_get_name()
CountriesApiTest::test_nullcountries_api_iso3_get_name function Function to test results of countries_api_iso3_get_name()
CountriesApiTest::test_results_countries_api_iso_get_country function Function to test _countries_api_iso_get_country returns a value
DrupalTestCase::$_cleanupModules property
DrupalTestCase::$_cleanupRoles property
DrupalTestCase::$_cleanupUsers property
DrupalTestCase::$_cleanupVariables property
DrupalTestCase::$_content property
DrupalTestCase::assertCopy function Will trigger a pass if both parameters refer to different objects. Fail otherwise.
DrupalTestCase::assertEqual function Will trigger a pass if the two parameters have the same value only. Otherwise a fail.
DrupalTestCase::assertError function Confirms that an error has occurred and optionally that the error text matches exactly.
DrupalTestCase::assertErrorPattern function Confirms that an error has occurred and that the error text matches a Perl regular expression.
DrupalTestCase::assertIdentical function Will trigger a pass if the two parameters have the same value and same type. Otherwise a fail.
DrupalTestCase::assertIsA function Type and class test. Will pass if class matches the type name or is a subclass or if not an object, but the type is correct.
DrupalTestCase::assertNoErrors function Confirms that no errors have occurred so far in the test method.
DrupalTestCase::assertNotA function Type and class mismatch test. Will pass if class name or underling type does not match the one specified.
DrupalTestCase::assertNotEqual function Will trigger a pass if the two parameters have a different value. Otherwise a fail.
DrupalTestCase::assertNotIdentical function Will trigger a pass if the two parameters have the different value or different type.
DrupalTestCase::assertNotNull function Will be true if the value is set.
DrupalTestCase::assertNoUnwantedPattern function Will trigger a pass if the Perl regex pattern is not present in subject. Fail if found.
DrupalTestCase::assertNoUnwantedRaw function Will trigger a pass if the raw text is NOT found on the loaded page Fail otherwise.
DrupalTestCase::assertNull function Will be true if the value is null.
DrupalTestCase::assertReference function Will trigger a pass if both parameters refer to the same object. Fail otherwise.
DrupalTestCase::assertWantedPattern function Will trigger a pass if the Perl regex pattern is found in the subject. Fail otherwise.
DrupalTestCase::assertWantedRaw function Will trigger a pass if the raw text is found on the loaded page Fail otherwise.
DrupalTestCase::clickLink function Follows a link by name. Will click the first link found with this link text by default, or a later one if an index is given. Match is case insensitive with normalised space. Does make assertations if the click was sucessful or not and it does…
DrupalTestCase::drupalCheckAuth function @abstract Checks to see if we need to send a http-auth header to authenticate when browsing a site.
DrupalTestCase::drupalCreateRolePerm function Create a role / perm combination specified by permissions
DrupalTestCase::drupalCreateUserRolePerm function Creates a user / role / permissions combination specified by permissions
DrupalTestCase::drupalGet function @abstract Brokder for the get function adds the authentication headers if necessary @author Earnest Berry III <earnest.berry@gmail.com>
DrupalTestCase::drupalGetContent function @TODO: needs documentation
DrupalTestCase::drupalLoginUser function Logs in a user with the internal browser
DrupalTestCase::drupalModuleDisable function Disables a drupal module
DrupalTestCase::drupalModuleEnable function Enables a drupal module
DrupalTestCase::drupalPostRequest function Do a post request on a drupal page. It will be done as usual post request with SimpleBrowser
DrupalTestCase::drupalRawPost function @abstract Broker for the post function adds the authentication headers if necessary @author Earnest Berry III <earnest.berry@gmail.com>
DrupalTestCase::DrupalTestCase function
DrupalTestCase::drupalVariableSet function Set a druapl variable and keep track of the changes for tearDown()
DrupalTestCase::randomName function Generates a random string, to be used as name or whatever
DrupalTestCase::run function Just some info for the reporter
DrupalTestCase::tearDown function tearDown implementation, setting back switched modules etc 1