You are here

public function FixedBlockAdminTest::doTestFixedBlockDeleteForm in Fixed Block Content 8

Tests the fixed block delete form.

See also

\Drupal\fixed_block_content\Form\FixedBlockContentDeleteForm

1 call to FixedBlockAdminTest::doTestFixedBlockDeleteForm()
FixedBlockAdminTest::testAdmin in tests/src/Functional/FixedBlockAdminTest.php
Full admin test sequence.

File

tests/src/Functional/FixedBlockAdminTest.php, line 168

Class

FixedBlockAdminTest
Tests the fixed block content admin.

Namespace

Drupal\Tests\fixed_block_content\Functional

Code

public function doTestFixedBlockDeleteForm() {

  // Block content must exists from previous step.
  $block_content_id = $this->fixedBlock
    ->getBlockContent(FALSE)
    ->id();

  // Go to delete the block content.
  $this
    ->drupalGet('admin/structure/block/block-content/fixed-block-content');
  $this
    ->clickLink('Delete');

  // The "Delete the linked custom block as well" must be present in the form.
  $this
    ->assertText('Delete the linked custom block as well');

  // Enable it.
  $edit = [
    'delete_linked_block' => TRUE,
  ];

  // Confirm the form.
  $this
    ->drupalPostForm(NULL, $edit, 'Delete');
  $this
    ->assertText('The fixed block content Basic fixed has been deleted.');

  // Test that the fixed block content was deleted.
  $this->fixedBlock = $this->container
    ->get('entity_type.manager')
    ->getStorage('fixed_block_content')
    ->load('basic_fixed');
  $this
    ->assertNull($this->fixedBlock);

  // Test that the block content was deleted as well.
  $block_content = $this->container
    ->get('entity_type.manager')
    ->getStorage('block_content')
    ->loadUnchanged($block_content_id);
  $this
    ->assertNull($block_content);
}