annotate core/modules/views/tests/src/Functional/RenderCacheWebTest.php @ 19:fa3358dc1485 tip

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