You are here

public function ProtectedFixedBlockTest::testNonProtectedBlockCreation in Fixed Block Content 8

Tests that a non-protected fixed block creates a reusable custom block.

File

tests/src/Kernel/ProtectedFixedBlockTest.php, line 17

Class

ProtectedFixedBlockTest
Tests the protected option of fixed blocks.

Namespace

Drupal\Tests\fixed_block_content\Kernel

Code

public function testNonProtectedBlockCreation() {

  // Test that the custom block content from a non protected fixed block is
  // reusable.
  $block_content = $this->fixedBlock
    ->getBlockContent();
  $this
    ->assertEquals(TRUE, $block_content
    ->isReusable());

  // Set the custom block to non-reusable.
  $block_content
    ->setNonReusable();

  // Export it to config. The reusable field will be stored in the default
  // content.
  $this->fixedBlock
    ->exportDefaultContent();

  // Delete it.
  $block_content
    ->delete();

  // Import the default non-reusable block by the not protected fixed block.
  $block_content = $this->fixedBlock
    ->getBlockContent();

  // The new block must be reusable despite the default content was exported
  // as non-reusable.
  $this
    ->assertEquals(TRUE, $block_content
    ->isReusable());
}