protected function CustomBlockTestBase::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. Defaults to 'basic'.

Return value

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

8 calls to CustomBlockTestBase::createCustomBlock()
CustomBlockBuildContentTest::testCustomBlockRebuildContent in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php
Ensures that content is rebuilt in calls to custom_block_build_content().
CustomBlockCreationTest::testFailedBlockCreation in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
Verifies that a transaction rolls back the failed creation.
CustomBlockLoadHooksTest::testHookCustomBlockLoad in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockLoadHooksTest.php
Tests that hook_custom_block_load() is invoked correctly.
CustomBlockPageViewTest::testPageEdit in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php
Checks block edit functionality.
CustomBlockRevisionsTest::setUp in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php
Sets the test up.

... See full list

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php, line 65
Contains \Drupal\custom_block\Tests\CustomBlockTestBase.

Class

CustomBlockTestBase
Sets up page and article content types.

Namespace

Drupal\custom_block\Tests

Code

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