protected function CustomBlockTranslationUITest::createCustomBlock

Creates a custom block.

Parameters

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

string $bundle: (optional) Bundle name. When no value is given, defaults to $this->bundle. Defaults to FALSE.

Return value

Drupal\custom_block\Plugin\Core\Entity\CustomBlock Created custom block.

1 call to CustomBlockTranslationUITest::createCustomBlock()
CustomBlockTranslationUITest::testDisabledBundle in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php
Test that no metadata is stored for a disabled bundle.

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php, line 83
Contains \Drupal\custom_block\Tests\CustomBlockTranslationUITest.

Class

CustomBlockTranslationUITest
Tests the Custom Block Translation UI.

Namespace

Drupal\custom_block\Tests

Code

protected function createCustomBlock($title = FALSE, $bundle = FALSE) {
  $title = $title ?: $this
    ->randomName();
  $bundle = $bundle ?: $this->bundle;
  $custom_block = entity_create('custom_block', array(
    'info' => $title,
    'type' => $bundle,
    'langcode' => 'en',
  ));
  $custom_block
    ->save();
  return $custom_block;
}