RenderCacheWebTest.php in Drupal 8
File
core/modules/views/tests/src/Functional/RenderCacheWebTest.php
View source
<?php
namespace Drupal\Tests\views\Functional;
use Drupal\node\Entity\Node;
class RenderCacheWebTest extends ViewTestBase {
public static $modules = [
'node',
'block',
];
protected $defaultTheme = 'classy';
public static $testViews = [
'node_id_argument',
];
protected $nodes;
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',
]);
}
public function testEmptyView() {
$this
->drupalGet('<front>');
$this
->assertEqual([], $this
->cssSelect('div.region-header div.views-field-title'));
$this
->drupalGet($this->nodes[0]
->toUrl());
$result = $this
->cssSelect('div.region-header div.views-field-title')[0]
->getText();
$this
->assertEqual('test title 1', $result);
$this
->drupalGet($this->nodes[1]
->toUrl());
$result = $this
->cssSelect('div.region-header div.views-field-title')[0]
->getText();
$this
->assertEqual('test title 2', $result);
$this
->drupalGet($this->nodes[0]
->toUrl());
$result = $this
->cssSelect('div.region-header div.views-field-title')[0]
->getText();
$this
->assertEqual('test title 1', $result);
}
}