public function BlockFieldPluginTest::testBlockCache in Display Suite 8.2
Cache contexts, tags and max-age on the block should get merged into the field build array
File
- src/
Tests/ BlockFieldPluginTest.php, line 141
Class
- BlockFieldPluginTest
- Tests for managing custom code, and block fields.
Namespace
Drupal\ds\TestsCode
public function testBlockCache() {
$block_field_id = Unicode::strtolower($this
->randomMachineName());
$entity_type = 'node';
$edit = [
'name' => $this
->randomString(),
'id' => $block_field_id,
'entities[' . $entity_type . ']' => TRUE,
'block' => 'ds_cache_test_block',
];
$this
->dsCreateBlockField($edit);
$fields['fields[dynamic_block_field:' . $entity_type . '-' . $block_field_id . '][region]'] = 'left';
$this
->dsSelectLayout();
$this
->dsConfigureUI($fields);
$settings['type'] = 'article';
$node = $this
->drupalCreateNode($settings);
// Check for query parameters
$this
->drupalGet($node
->toUrl(), [
'query' => [
'cached' => 1,
],
]);
$this
->assertRaw('cached=1');
// Check for query parameters
$this
->drupalGet($node
->toUrl(), [
'query' => [
'cached' => 2,
],
]);
$this
->assertRaw('cached=2');
}