public function FixedToContentMappingTest::testReleaseBlockContent in Fixed Block Content 8
Tests the block content release method.
File
- tests/
src/ Kernel/ FixedToContentMappingTest.php, line 96
Class
- FixedToContentMappingTest
- Tests the fixed block content mapping handler.
Namespace
Drupal\Tests\fixed_block_content\KernelCode
public function testReleaseBlockContent() {
// Release on not linked fixed should silently exit.
$this->mappingHandler
->releaseBlockContent($this->fixedBlock);
// Get the block content. A new one will be created and linked.
$block_id = $this->fixedBlock
->getBlockContent()
->id();
// Release the block content.
$this->mappingHandler
->releaseBlockContent($this->fixedBlock);
// The block content shouldn't be deleted.
$this
->assertNotNull($this->entityTypeManager
->getStorage('block_content')
->load($block_id));
// The fixed block should be released.
$this
->assertEmpty($this->fixedBlock
->getBlockContent(FALSE));
// Enable de protected options.
$this->fixedBlock
->setProtected();
// Get the block content. A new one will be created and linked.
$block_id = $this->fixedBlock
->getBlockContent()
->id();
// Release the block content.
$this->mappingHandler
->releaseBlockContent($this->fixedBlock);
// The non-reusable block content should be deleted.
$this
->assertNull($this->entityTypeManager
->getStorage('block_content')
->load($block_id));
// The fixed block should be released.
$this
->assertEmpty($this->fixedBlock
->getBlockContent(FALSE));
}