You are here

public function ProtectedFixedBlockTest::testProtectedBlockDeletion in Fixed Block Content 8

Tests non-reusable block content deletion removes the link with its fixed.

File

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

Class

ProtectedFixedBlockTest
Tests the protected option of fixed blocks.

Namespace

Drupal\Tests\fixed_block_content\Kernel

Code

public function testProtectedBlockDeletion() {

  // Enables the protected option.
  $this->fixedBlock
    ->setProtected();

  // Get the block content, will create a new one.
  $block_content = $this->fixedBlock
    ->getBlockContent();

  // Delete the non-reusable block content.
  $block_content
    ->delete();

  // Check that the link with its fixed was removed.
  $connection = Database::getConnection();
  $count = $connection
    ->select('fixed_block_content', 'fbc')
    ->condition('fbc.fbid', $this->fixedBlock
    ->id())
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertEmpty($count, 'Fixed block link with a deleted block content was found.');
}