public function AutoExportTest::testAutoExportOnEmpty in Fixed Block Content 8
Tests the automatic block content creation with no existing blocks.
File
- tests/
src/ Kernel/ AutoExportTest.php, line 44
Class
- AutoExportTest
- Tests the auto-create option of fixed blocks.
Namespace
Drupal\Tests\fixed_block_content\KernelCode
public function testAutoExportOnEmpty() {
// Perform a config import. This will re add the default content cleared in
// the setup.
$this
->configImporter()
->import();
// Check that there is no block content for the fixed block with
// the auto-export option disabled.
/** @var \Drupal\fixed_block_content\FixedBlockContentInterface $fixed_block */
$entity_storage = $this->entityTypeManager
->getStorage('fixed_block_content');
$fixed_block = $entity_storage
->load('test_auto_export_disabled');
$this
->assertNull($fixed_block
->getBlockContent(FALSE));
// Check that the fixed block with the auto-export on empty option
// has a block content linked.
$fixed_block = $entity_storage
->load('auto_export_on_empty');
$block_content = $fixed_block
->getBlockContent(FALSE);
$this
->assertNotNull($block_content);
// Check that the fixed block with the auto-export always option
// has a block content linked.
$fixed_block = $entity_storage
->load('auto_export_always');
$block_content = $fixed_block
->getBlockContent(FALSE);
$this
->assertNotNull($block_content);
}