You are here

protected function BlockContentTestBase::createBlockContent in Drupal 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/tests/src/Functional/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\BlockContentTestBase::createBlockContent()
  3. 8 core/modules/block_content/src/Tests/Views/BlockContentTestBase.php \Drupal\block_content\Tests\Views\BlockContentTestBase::createBlockContent()
  4. 8 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\Views\BlockContentTestBase::createBlockContent()

Creates a custom block.

Parameters

array $values: (optional) The values for the block_content entity.

Return value

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

File

core/modules/block_content/src/Tests/Views/BlockContentTestBase.php, line 69

Class

BlockContentTestBase
Base class for all block_content tests.

Namespace

Drupal\block_content\Tests\Views

Code

protected function createBlockContent(array $values = []) {
  $status = 0;
  $values += [
    'info' => $this
      ->randomMachineName(),
    'type' => 'basic',
    'langcode' => 'en',
  ];
  if ($block_content = BlockContent::create($values)) {
    $status = $block_content
      ->save();
  }
  $this
    ->assertEqual($status, SAVED_NEW, new FormattableMarkup('Created block content %info.', [
    '%info' => $block_content
      ->label(),
  ]));
  return $block_content;
}