function BlockContentCreationTest::testBlockContentCreation
Same name in other branches
- 9 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testBlockContentCreation()
- 8.9.x core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testBlockContentCreation()
- 11.x core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testBlockContentCreation()
Creates a "Basic block" block and verifies its consistency in the database.
File
-
core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php, line 58
Class
- BlockContentCreationTest
- Create a block and test saving it.
Namespace
Drupal\Tests\block_content\FunctionalCode
public function testBlockContentCreation() : void {
$this->drupalLogin($this->adminUser);
// Create a block.
$edit = [];
$edit['info[0][value]'] = 'Test Block';
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalGet('block/add/basic');
$this->submitForm($edit, 'Save');
// Check that the Basic block has been created.
$this->assertSession()
->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
// Check that the view mode setting is hidden because only one exists.
$this->assertSession()
->fieldNotExists('settings[view_mode]');
// Check that the block exists in the database.
$block = $this->getBlockByLabel($edit['info[0][value]']);
$this->assertNotEmpty($block, 'Content Block found in database.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.