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/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\BlockContentTestBase::createBlockContentType()
  2. 10 core/modules/block_content/tests/src/Functional/BlockContentTestBase.php \Drupal\Tests\block_content\Functional\BlockContentTestBase::createBlockContentType()

Creates a custom block type (bundle).

Parameters

string $label: The block type label.

bool $create_body: Whether or not to create the body field

Return value

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

6 calls to BlockContentTestBase::createBlockContentType()
BlockContentTestBase::setUp in core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
Sets the test up.
BlockContentTypeTest::testBlockContentTypeCreation in core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
Tests creating a block type programmatically and via a form.
BlockContentTypeTest::testBlockContentTypeDeletion in core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
Tests deleting a block type that still has content.
BlockContentTypeTest::testBlockContentTypeEditing in core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
Tests editing a block type using the UI.
BlockContentTypeTest::testsBlockContentAddTypes in core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
Tests that redirects work as expected when multiple block types exist.

... See full list

File

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

Class

BlockContentTestBase
Sets up block content types.

Namespace

Drupal\Tests\block_content\Functional

Code

protected function createBlockContentType($label, $create_body = FALSE) {
  $bundle = BlockContentType::create([
    'id' => $label,
    'label' => $label,
    'revision' => FALSE,
  ]);
  $bundle
    ->save();
  if ($create_body) {
    block_content_add_body_field($bundle
      ->id());
  }
  return $bundle;
}