DsFieldCacheTest.php in Display Suite 8.4
File
tests/src/Functional/DsFieldCacheTest.php
View source
<?php
namespace Drupal\Tests\ds\Functional;
use Drupal\Core\Cache\Cache;
use Drupal\Tests\node\Traits\NodeCreationTrait;
class DsFieldCacheTest extends TestBase {
use NodeCreationTrait;
use DsTestTrait;
public static $modules = [
'page_cache',
'dynamic_page_cache',
];
public function setUp() {
parent::setUp();
$this
->drupalLogin($this->adminUser);
}
public function testCachedDsField() {
$fields = [
'fields[test_caching_field][region]' => 'left',
'fields[test_caching_field][label]' => 'above',
];
$this
->drupalGet('admin/structure/types/manage/article/display');
$this
->submitForm([
'ds_layout' => 'ds_2col',
], 'Save');
$this
->dsConfigureUi($fields);
$node = $this
->createNode([
'type' => 'article',
]);
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->pageTextNotContains('DsField Shown');
\Drupal::state()
->set('ds_test_show_field', TRUE);
Cache::invalidateTags([
'ds_my_custom_tags',
]);
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->pageTextContains('DsField Shown');
}
}