You are here

protected function ip2countryTestCase::setUp in IP-based Determination of a Visitor's Country 7

Same name and namespace in other branches
  1. 6 ip2country.test \ip2countryTestCase::setUp()

Overrides DrupalWebTestCase::setUp().

Overrides DrupalWebTestCase::setUp

File

tests/ip2country.test, line 45
Tests suite for the ip2country module.

Class

ip2countryTestCase
Tests operations of the IP to Country module.

Code

protected function setUp() {

  //
  // Don't install ip2country! parent::setUp() creates a clean
  // environment, so we can influence the install before we call setUp().
  // We don't want the DB populated, so we'll manually install ip2country.
  //
  parent::setUp();

  //
  // Set a run-time long enough so the script won't break.
  //
  $this->timeLimit = 3 * 60;

  // 3 minutes!
  drupal_set_time_limit($this->timeLimit);

  // Turn off automatic DB download when module is installed.
  variable_set('ip2country_populate_database_on_install', FALSE);

  // Explicitly enable the module so that it will have access
  // to the variable we set above.
  $status = module_enable(array(
    'ip2country',
  ), FALSE);
  $this
    ->resetAll();

  // The secret ingredient.
  $this
    ->assertTrue($status, t('Module %module enabled.', array(
    '%module' => 'ip2country',
  )));
  $this
    ->assertTrue(ip2country_get_count() == 0, t('Database is empty.'));

  // Create our test users.
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'administer site configuration',
    'access administration pages',
    'access site reports',
    'administer ip2country',
  ));
  $this->unprivUser = $this
    ->drupalCreateUser();
}