profile != 'standard') { $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); } $this->authUser = $this->drupalCreateUser([ // 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(['title' => $this->randomMachineName(255), 'uid' => $this->authUser->id()]); // Add a custom language and enable path-based language negotiation. $this->drupalLogin($this->authUser); $this->language = [ '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', ['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::httpClient(); } /** * Verifies node hit counter logging and script placement. */ public function testLogging() { $path = 'node/' . $this->node->id(); $module_path = drupal_get_path('module', 'statistics'); $stats_path = base_path() . $module_path . '/statistics.php'; $lib_path = base_path() . $module_path . '/statistics.js'; $expected_library = '/