StatisticsAttachedTest.php in Drupal 8
File
core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php
View source
<?php
namespace Drupal\Tests\statistics\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\node\Entity\Node;
class StatisticsAttachedTest extends BrowserTestBase {
public static $modules = [
'node',
'statistics',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
]);
$theme = 'statistics_test_attached';
\Drupal::service('theme_installer')
->install([
$theme,
]);
$this
->config('system.theme')
->set('default', $theme)
->save();
\Drupal::service('router.builder')
->rebuildIfNeeded();
}
public function testAttached() {
$node = Node::create([
'type' => 'page',
'title' => 'Page node',
'body' => 'body text',
]);
$node
->save();
$this
->drupalGet('node/' . $node
->id());
$this
->assertRaw('core/modules/statistics/statistics.js', 'Statistics library is available');
}
}