protected function StatisticsLoggingTest::setUp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/statistics/src/Tests/StatisticsLoggingTest.php \Drupal\statistics\Tests\StatisticsLoggingTest::setUp()
Sets up a Drupal site for running functional and integration tests.
Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.
Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Overrides WebTestBase::setUp
File
- core/
modules/ statistics/ src/ Tests/ StatisticsLoggingTest.php, line 50 - Contains \Drupal\statistics\Tests\StatisticsLoggingTest.
Class
- StatisticsLoggingTest
- Tests request logging for cached and uncached pages.
Namespace
Drupal\statistics\TestsCode
protected function setUp() {
parent::setUp();
// Create Basic page node type.
if ($this->profile != 'standard') {
$this
->drupalCreateContentType(array(
'type' => 'page',
'name' => 'Basic page',
));
}
$this->authUser = $this
->drupalCreateUser(array(
// For node creation.
'access content',
'create page content',
'edit own page content',
// For language negotiation administration.
'administer languages',
'access administration pages',
));
// Ensure we have a node page to access.
$this->node = $this
->drupalCreateNode(array(
'title' => $this
->randomMachineName(255),
'uid' => $this->authUser
->id(),
));
// Add a custom language and enable path-based language negotiation.
$this
->drupalLogin($this->authUser);
$this->language = array(
'predefined_langcode' => 'custom',
'langcode' => 'xx',
'label' => $this
->randomMachineName(16),
'direction' => 'ltr',
);
$this
->drupalPostForm('admin/config/regional/language/add', $this->language, t('Add custom language'));
$this
->drupalPostForm('admin/config/regional/language/detection', array(
'language_interface[enabled][language-url]' => 1,
), t('Save settings'));
$this
->drupalLogout();
// Enable access logging.
$this
->config('statistics.settings')
->set('count_content_views', 1)
->save();
// Clear the logs.
db_truncate('node_counter');
$this->client = \Drupal::service('http_client_factory')
->fromOptions([
'config/curl' => [
CURLOPT_TIMEOUT => 10,
],
]);
}