You are here

protected function BlockContentTestBase::createBlockContentType in Zircon Profile 8

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

Creates a custom block type (bundle).

Parameters

array $values: An array of settings to change from the defaults.

Return value

\Drupal\block_content\Entity\BlockContentType Created custom block type.

2 calls to BlockContentTestBase::createBlockContentType()
BlockContentIntegrationTest::testBlockContentViewTypeArgument in core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php
Tests basic block_content view with a block_content_type argument.
BlockContentTestBase::setUp in core/modules/block_content/src/Tests/Views/BlockContentTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

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

Class

BlockContentTestBase
Base class for all block_content tests.

Namespace

Drupal\block_content\Tests\Views

Code

protected function createBlockContentType(array $values = array()) {

  // Find a non-existent random type name.
  if (!isset($values['id'])) {
    do {
      $id = strtolower($this
        ->randomMachineName(8));
    } while (BlockContentType::load($id));
  }
  else {
    $id = $values['id'];
  }
  $values += array(
    'id' => $id,
    'label' => $id,
    'revision' => FALSE,
  );
  $bundle = entity_create('block_content_type', $values);
  $status = $bundle
    ->save();
  block_content_add_body_field($bundle
    ->id());
  $this
    ->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', array(
    '%bundle' => $bundle
      ->id(),
  )));
  return $bundle;
}