Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* @file
* Contains \Drupal\views\Tests\RenderCacheWebTest.
*/
namespace Drupal\views\Tests;
use Drupal\node\Entity\Node;
/**
* Tests render caching of blocks provided by views.
*
* @group views
*/
class RenderCacheWebTest extends ViewTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'block'];
/**
* {@inheritdoc}
*/
public static $testViews = ['node_id_argument'];
/**
* The created nodes.
*
* @var \Drupal\node\NodeInterface[]
*/
protected $nodes;
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$node_type = $this->drupalCreateContentType(['type' => 'test_type']);
$node = Node::create([
'title' => 'test title 1',
'type' => $node_type->id(),
]);
$node->save();
$this->nodes[] = $node;
$node = Node::create([
'title' => 'test title 2',
'type' => $node_type->id(),
]);
$node->save();
$this->nodes[] = $node;
$this->placeBlock('views_block:node_id_argument-block_1', ['region' => 'header']);
}
/**
* Tests rendering caching of a views block with arguments.
*/
public function testEmptyView() {
$this->drupalGet('<front>');
$this->assertEqual([], $this->cssSelect('div.region-header div.views-field-title'));
$this->drupalGet($this->nodes[0]->toUrl());
$result = (string) $this->cssSelect('div.region-header div.views-field-title')[0]->span;
$this->assertEqual('test title 1', $result);
$this->drupalGet($this->nodes[1]->toUrl());
$result = (string) $this->cssSelect('div.region-header div.views-field-title')[0]->span;
$this->assertEqual('test title 2', $result);
$this->drupalGet($this->nodes[0]->toUrl());
$result = (string) $this->cssSelect('div.region-header div.views-field-title')[0]->span;
$this->assertEqual('test title 1', $result);
}
}