protected function Ip2CountryTest::setUp in IP-based Determination of a Visitor's Country 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ Ip2CountryTest.php, line 47
Class
- Ip2CountryTest
- Tests operations of the IP to Country module.
Namespace
Drupal\Tests\ip2country\FunctionalCode
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!
Environment::setTimeLimit($this->timeLimit);
// Turn off automatic DB download when module is installed.
\Drupal::state()
->set('ip2country_populate_database_on_install', FALSE);
// Explicitly install the module so that it will have access
// to the configuration variable we set above.
$status = \Drupal::service('module_installer')
->install([
'ip2country',
], FALSE);
$this
->resetAll();
// The secret ingredient.
$this
->assertTrue($status, 'Module ip2country enabled.');
$count = \Drupal::service('ip2country.manager')
->getRowCount();
$this
->assertEquals(0, $count, 'Database is empty.');
// System help block is needed to see output from hook_help().
$this
->drupalPlaceBlock('help_block', [
'region' => 'help',
]);
// Need page_title_block because we test page titles.
$this
->drupalPlaceBlock('page_title_block');
// Create our test users.
$this->adminUser = $this
->drupalCreateUser([
'administer site configuration',
'access administration pages',
'access site reports',
'administer ip2country',
]);
$this->unprivUser = $this
->drupalCreateUser();
}