3 namespace Drupal\Tests\views\Functional;
5 use Drupal\node\Entity\Node;
8 * Tests render caching of blocks provided by views.
12 class RenderCacheWebTest extends ViewTestBase {
17 public static $modules = ['node', 'block'];
22 public static $testViews = ['node_id_argument'];
27 * @var \Drupal\node\NodeInterface[]
34 protected function setUp($import_test_views = TRUE) {
35 parent::setUp($import_test_views);
37 $node_type = $this->drupalCreateContentType(['type' => 'test_type']);
38 $node = Node::create([
39 'title' => 'test title 1',
40 'type' => $node_type->id(),
43 $this->nodes[] = $node;
45 $node = Node::create([
46 'title' => 'test title 2',
47 'type' => $node_type->id(),
50 $this->nodes[] = $node;
52 $this->placeBlock('views_block:node_id_argument-block_1', ['region' => 'header']);
56 * Tests rendering caching of a views block with arguments.
58 public function testEmptyView() {
59 $this->drupalGet('<front>');
60 $this->assertEqual([], $this->cssSelect('div.region-header div.views-field-title'));
62 $this->drupalGet($this->nodes[0]->toUrl());
63 $result = $this->cssSelect('div.region-header div.views-field-title')[0]->getText();
64 $this->assertEqual('test title 1', $result);
66 $this->drupalGet($this->nodes[1]->toUrl());
67 $result = $this->cssSelect('div.region-header div.views-field-title')[0]->getText();
68 $this->assertEqual('test title 2', $result);
70 $this->drupalGet($this->nodes[0]->toUrl());
71 $result = $this->cssSelect('div.region-header div.views-field-title')[0]->getText();
72 $this->assertEqual('test title 1', $result);