public function DsFieldCacheTest::testCachedDsField in Display Suite 8.4
Same name and namespace in other branches
- 8.3 tests/src/Functional/DsFieldCacheTest.php \Drupal\Tests\ds\Functional\DsFieldCacheTest::testCachedDsField()
Test a DS field that returns cache data.
Throws
\Drupal\Core\Entity\EntityMalformedException
\Behat\Mink\Exception\ResponseTextException
File
- tests/
src/ Functional/ DsFieldCacheTest.php, line 34
Class
- DsFieldCacheTest
- Cache field test.
Namespace
Drupal\Tests\ds\FunctionalCode
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);
// Create and visit the node so that it is cached as empty, ensure the title
// doesn't appear.
$node = $this
->createNode([
'type' => 'article',
]);
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->pageTextNotContains('DsField Shown');
// Enable our toggle flag and invalidate the cache so that our field should
// appear.
\Drupal::state()
->set('ds_test_show_field', TRUE);
Cache::invalidateTags([
'ds_my_custom_tags',
]);
// Visit the node and assert that it now appears.
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->pageTextContains('DsField Shown');
}