public function FacetTest::testBlockCache in Facets 8
Tests that the block caches are cleared from API calls.
@covers ::postSave @covers ::postDelete @covers ::clearBlockCache
File
- tests/
src/ Kernel/ Entity/ FacetTest.php, line 397
Class
- FacetTest
- Class FacetTest.
Namespace
Drupal\Tests\facets\Kernel\EntityCode
public function testBlockCache() {
// Block processing requires the system module.
$this
->enableModules([
'system',
]);
// Create our facet.
$entity = Facet::create([
'id' => 'test_facet',
'name' => 'Test facet',
]);
$entity
->setWidget('links');
$entity
->setEmptyBehavior([
'behavior' => 'none',
]);
$block_id = 'facet_block' . PluginBase::DERIVATIVE_SEPARATOR . $entity
->id();
// Check we don't have a block yet.
$this
->assertFalse($this->container
->get('plugin.manager.block')
->hasDefinition($block_id));
// Save our facet.
$entity
->save();
// Check our block exists.
$this
->assertTrue($this->container
->get('plugin.manager.block')
->hasDefinition($block_id));
// Delete our facet.
$entity
->delete();
// Check our block exists.
$this
->assertFalse($this->container
->get('plugin.manager.block')
->hasDefinition($block_id));
}