You are here

protected function BlockContentTestBase::createBlockContent in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/block_content/src/Tests/BlockContentTestBase.php \Drupal\block_content\Tests\BlockContentTestBase::createBlockContent()
  2. 8 core/modules/block_content/src/Tests/Views/BlockContentTestBase.php \Drupal\block_content\Tests\Views\BlockContentTestBase::createBlockContent()
Same name and namespace in other branches
  1. 8.0 core/modules/block_content/src/Tests/BlockContentTestBase.php \Drupal\block_content\Tests\BlockContentTestBase::createBlockContent()

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.

8 calls to BlockContentTestBase::createBlockContent()
BlockContentCreationTest::testConfigDependencies in core/modules/block_content/src/Tests/BlockContentCreationTest.php
Test that placed content blocks create a dependency in the block placement.
BlockContentCreationTest::testFailedBlockCreation in core/modules/block_content/src/Tests/BlockContentCreationTest.php
Verifies that a transaction rolls back the failed creation.
BlockContentPageViewTest::testPageEdit in core/modules/block_content/src/Tests/BlockContentPageViewTest.php
Checks block edit and fallback functionality.
BlockContentRevisionsTest::setUp in core/modules/block_content/src/Tests/BlockContentRevisionsTest.php
Sets the test up.
BlockContentSaveTest::testBlockContentSaveOnInsert in core/modules/block_content/src/Tests/BlockContentSaveTest.php
Tests saving a block on block insert.

... See full list

File

core/modules/block_content/src/Tests/BlockContentTestBase.php, line 79
Contains \Drupal\block_content\Tests\BlockContentTestBase.

Class

BlockContentTestBase
Sets up block content types.

Namespace

Drupal\block_content\Tests

Code

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