function 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\ViewsCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.