Same name and namespace in other branches
  1. 8.9.x core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testDefaultBlockContentCreation()
  2. 9 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testDefaultBlockContentCreation()

Create a default content block.

Creates a content block from defaults and ensures that the 'basic block' type is being used.

File

core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php, line 196

Class

BlockContentCreationTest
Create a block and test saving it.

Namespace

Drupal\Tests\block_content\Functional

Code

public function testDefaultBlockContentCreation() {
  $edit = [];
  $edit['info[0][value]'] = $this
    ->randomMachineName(8);
  $edit['body[0][value]'] = $this
    ->randomMachineName(16);

  // Don't pass the content block type in the URL so the default is forced.
  $this
    ->drupalGet('block/add');
  $this
    ->submitForm($edit, 'Save');

  // Check that the block has been created and that it is a basic block.
  $this
    ->assertSession()
    ->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');

  // Check that the block exists in the database.
  $block = $this
    ->getBlockByLabel($edit['info[0][value]']);
  $this
    ->assertNotEmpty($block, 'Default Content Block found in database.');
}