class StatisticsAttachedTest
Same name and namespace in other branches
- 10 core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php \Drupal\Tests\statistics\Functional\StatisticsAttachedTest
- 8.9.x core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php \Drupal\Tests\statistics\Functional\StatisticsAttachedTest
Tests if statistics.js is loaded when content is not printed.
@group statistics
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\statistics\Functional\StatisticsAttachedTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of StatisticsAttachedTest
File
-
core/
modules/ statistics/ tests/ src/ Functional/ StatisticsAttachedTest.php, line 13
Namespace
Drupal\Tests\statistics\FunctionalView source
class StatisticsAttachedTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
'statistics',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->drupalCreateContentType([
'type' => 'page',
]);
// Install "statistics_test_attached" and set it as the default theme.
$theme = 'statistics_test_attached';
\Drupal::service('theme_installer')->install([
$theme,
]);
$this->config('system.theme')
->set('default', $theme)
->save();
// Installing a theme will cause the kernel terminate event to rebuild the
// router. Simulate that here.
\Drupal::service('router.builder')->rebuildIfNeeded();
}
/**
* Tests if statistics.js is loaded when content is not printed.
*/
public function testAttached() {
$node = Node::create([
'type' => 'page',
'title' => 'Page node',
'body' => 'body text',
]);
$node->save();
$this->drupalGet('node/' . $node->id());
$this->assertSession()
->responseContains('core/modules/statistics/statistics.js');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.