comparison core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\statistics\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\node\Entity\Node;
7
8 /**
9 * Tests if statistics.js is loaded when content is not printed.
10 *
11 * @group statistics
12 */
13 class StatisticsAttachedTest extends BrowserTestBase {
14
15 /**
16 * Modules to enable.
17 *
18 * @var array
19 */
20 public static $modules = ['node', 'statistics'];
21
22 /**
23 * {@inheritdoc}
24 */
25 protected function setUp() {
26 parent::setUp();
27
28 $this->drupalCreateContentType(['type' => 'page']);
29
30 // Install "statistics_test_attached" and set it as the default theme.
31 $theme = 'statistics_test_attached';
32 \Drupal::service('theme_handler')->install([$theme]);
33 $this->config('system.theme')
34 ->set('default', $theme)
35 ->save();
36 // Installing a theme will cause the kernel terminate event to rebuild the
37 // router. Simulate that here.
38 \Drupal::service('router.builder')->rebuildIfNeeded();
39 }
40
41 /**
42 * Tests if statistics.js is loaded when content is not printed.
43 */
44 public function testAttached() {
45
46 $node = Node::create([
47 'type' => 'page',
48 'title' => 'Page node',
49 'body' => 'body text'
50 ]);
51 $node->save();
52 $this->drupalGet('node/' . $node->id());
53
54 $this->assertRaw('core/modules/statistics/statistics.js', 'Statistics library is available');
55 }
56
57 }