Mercurial > hg > isophonics-drupal-site
comparison core/modules/views/tests/src/Functional/RenderCacheWebTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\views\Functional; | |
4 | |
5 use Drupal\node\Entity\Node; | |
6 | |
7 /** | |
8 * Tests render caching of blocks provided by views. | |
9 * | |
10 * @group views | |
11 */ | |
12 class RenderCacheWebTest extends ViewTestBase { | |
13 | |
14 /** | |
15 * {@inheritdoc} | |
16 */ | |
17 public static $modules = ['node', 'block']; | |
18 | |
19 /** | |
20 * {@inheritdoc} | |
21 */ | |
22 public static $testViews = ['node_id_argument']; | |
23 | |
24 /** | |
25 * The created nodes. | |
26 * | |
27 * @var \Drupal\node\NodeInterface[] | |
28 */ | |
29 protected $nodes; | |
30 | |
31 /** | |
32 * {@inheritdoc} | |
33 */ | |
34 protected function setUp($import_test_views = TRUE) { | |
35 parent::setUp($import_test_views); | |
36 | |
37 $node_type = $this->drupalCreateContentType(['type' => 'test_type']); | |
38 $node = Node::create([ | |
39 'title' => 'test title 1', | |
40 'type' => $node_type->id(), | |
41 ]); | |
42 $node->save(); | |
43 $this->nodes[] = $node; | |
44 | |
45 $node = Node::create([ | |
46 'title' => 'test title 2', | |
47 'type' => $node_type->id(), | |
48 ]); | |
49 $node->save(); | |
50 $this->nodes[] = $node; | |
51 | |
52 $this->placeBlock('views_block:node_id_argument-block_1', ['region' => 'header']); | |
53 } | |
54 | |
55 /** | |
56 * Tests rendering caching of a views block with arguments. | |
57 */ | |
58 public function testEmptyView() { | |
59 $this->drupalGet('<front>'); | |
60 $this->assertEqual([], $this->cssSelect('div.region-header div.views-field-title')); | |
61 | |
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); | |
65 | |
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); | |
69 | |
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); | |
73 } | |
74 | |
75 } |