You are here

protected function SettingsTrayIntegrationTest::createBlockContent in Drupal 9

Creates a custom block.

Parameters

bool|string $title: (optional) Title of block. When no value is given uses a random name. Defaults to FALSE.

string $bundle: (optional) Bundle name. Defaults to 'basic'.

bool $save: (optional) Whether to save the block. Defaults to TRUE.

Return value

\Drupal\block_content\Entity\BlockContent Created custom block.

1 call to SettingsTrayIntegrationTest::createBlockContent()
SettingsTrayIntegrationTest::testCustomBlockLinks in core/modules/quickedit/tests/src/FunctionalJavascript/SettingsTrayIntegrationTest.php
Tests that contextual links in custom blocks are changed.

File

core/modules/quickedit/tests/src/FunctionalJavascript/SettingsTrayIntegrationTest.php, line 172

Class

SettingsTrayIntegrationTest
Test Settings Tray and Quick Edit modules integration.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
  $title = $title ?: $this
    ->randomName();
  $block_content = BlockContent::create([
    'info' => $title,
    'type' => $bundle,
    'langcode' => 'en',
    'body' => [
      'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
      'format' => 'plain_text',
    ],
  ]);
  if ($block_content && $save === TRUE) {
    $block_content
      ->save();
  }
  return $block_content;
}