function ip2countryTestCase::setUp in IP-based Determination of a Visitor's Country 6
Same name and namespace in other branches
- 7 tests/ip2country.test \ip2countryTestCase::setUp()
Overrides DrupalWebTestCase::setUp().
Overrides DrupalWebTestCase::setUp
File
- ./
ip2country.test, line 43 - Tests suite for the ip2country module.
Class
- ip2countryTestCase
- Need 1 class for unit tests, 1 class for functional tests 1 function for DB tests because filling takes so long
Code
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!
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.
drupal_install_modules(array(
'countries_api',
'ip2country',
));
$this
->resetAll();
// The secret ingredient
$this
->assertTrue(module_exists('countries_api'), t('Module %module enabled.', array(
'%module' => 'countries_api',
)));
$this
->assertTrue(module_exists('ip2country'), t('Module %module enabled.', array(
'%module' => 'ip2country',
)));
$this
->assertTrue(ip2country_get_count() == 0, t('Database is empty.'));
// Create our test users.
$this->admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'access administration pages',
'access site reports',
'administer ip2country',
));
$this->unpriv_user = $this
->drupalCreateUser();
}