You are here

protected function LayoutBuilderTest::createBlockContent in Block Style Plugins 8.2

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 LayoutBuilderTest::createBlockContent()
LayoutBuilderTest::testLayoutBuilderCustomBlockVisibility in tests/src/FunctionalJavascript/LayoutBuilderTest.php
Tests that styles are correctly included/excluded from custom blocks.

File

tests/src/FunctionalJavascript/LayoutBuilderTest.php, line 302

Class

LayoutBuilderTest
Layout Builder tests.

Namespace

Drupal\Tests\block_style_plugins\FunctionalJavascript

Code

protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
  $title = $title ?: $this
    ->randomMachineName();
  $block_content = BlockContent::create([
    'info' => $title,
    'type' => $bundle,
    'langcode' => 'en',
  ]);
  if ($block_content && $save === TRUE) {
    $block_content
      ->save();
  }
  return $block_content;
}