You are here

protected function BlockContentTestBase::createBlockContentType in Drupal 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/tests/src/Functional/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\BlockContentTestBase::createBlockContentType()
  3. 8 core/modules/block_content/src/Tests/Views/BlockContentTestBase.php \Drupal\block_content\Tests\Views\BlockContentTestBase::createBlockContentType()
  4. 8 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\Views\BlockContentTestBase::createBlockContentType()
Same name and namespace in other branches
  1. 9 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\Views\BlockContentTestBase::createBlockContentType()
  2. 10 core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\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/tests/src/Functional/Views/BlockContentIntegrationTest.php
Tests basic block_content view with a block_content_type argument.
BlockContentTestBase::setUp in core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php

File

core/modules/block_content/tests/src/Functional/Views/BlockContentTestBase.php, line 87

Class

BlockContentTestBase
Base class for all block_content tests.

Namespace

Drupal\Tests\block_content\Functional\Views

Code

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

  // 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 += [
    'id' => $id,
    'label' => $id,
    'revision' => FALSE,
  ];
  $bundle = BlockContentType::create($values);
  $status = $bundle
    ->save();
  block_content_add_body_field($bundle
    ->id());
  $this
    ->assertEqual($status, SAVED_NEW, new FormattableMarkup('Created block content type %bundle.', [
    '%bundle' => $bundle
      ->id(),
  ]));
  return $bundle;
}