function BlockContentTypeTest::testBlockContentTypeDeletion
Same name in other branches
- 9 core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php \Drupal\Tests\block_content\Functional\BlockContentTypeTest::testBlockContentTypeDeletion()
- 8.9.x core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php \Drupal\Tests\block_content\Functional\BlockContentTypeTest::testBlockContentTypeDeletion()
- 10 core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php \Drupal\Tests\block_content\Functional\BlockContentTypeTest::testBlockContentTypeDeletion()
Tests deleting a block type that still has content.
File
-
core/
modules/ block_content/ tests/ src/ Functional/ BlockContentTypeTest.php, line 175
Class
- BlockContentTypeTest
- Ensures that block type functions work correctly.
Namespace
Drupal\Tests\block_content\FunctionalCode
public function testBlockContentTypeDeletion() : void {
// Now create an initial block-type.
$this->createBlockContentType([
'id' => 'basic',
], TRUE);
// Create a block type programmatically.
$type = $this->createBlockContentType([
'id' => '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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.