public function testBlockContentTypeDeletion() { // Now create an initial block-type.
$this->
createBlockContentType('basic', TRUE
);
// Create a block type programmatically.
$type =
$this->
createBlockContentType('foo'
);
$this->
drupalLogin($this->adminUser
);
// Add a new block of this type.
$block =
$this->
createBlockContent(FALSE, 'foo'
);
// Attempt to delete the block type, which should not be allowed.
$this->
drupalGet('admin/structure/block-content/manage/' .
$type->
id() . '/delete'
);
$this->
assertSession()->
pageTextContains($type->
label() . ' is used by 1 content block on your site. You can not remove this block type until you have removed all of the ' .
$type->
label() . ' blocks.'
);
$this->
assertSession()->
pageTextNotContains('This action cannot be undone.'
);
// Delete the block.
$block->
delete();
// Attempt to delete the block type, which should now be allowed.
$this->
drupalGet('admin/structure/block-content/manage/' .
$type->
id() . '/delete'
);
$this->
assertSession()->
pageTextContains('Are you sure you want to delete the block type ' .
$type->
id() . '?'
);
$this->
assertSession()->
pageTextContains('This action cannot be undone.'
);
}