function BlockContentTest::createEntity
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/BlockContentTest.php \Drupal\Tests\jsonapi\Functional\BlockContentTest::createEntity()
- 8.9.x core/modules/jsonapi/tests/src/Functional/BlockContentTest.php \Drupal\Tests\jsonapi\Functional\BlockContentTest::createEntity()
- 11.x core/modules/jsonapi/tests/src/Functional/BlockContentTest.php \Drupal\Tests\jsonapi\Functional\BlockContentTest::createEntity()
Overrides ResourceTestBase::createEntity
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ BlockContentTest.php, line 106
Class
- BlockContentTest
- JSON:API integration test for the "BlockContent" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function createEntity() {
if (!BlockContentType::load('basic')) {
$block_content_type = BlockContentType::create([
'id' => 'basic',
'label' => 'basic',
'revision' => TRUE,
]);
$block_content_type->save();
block_content_add_body_field($block_content_type->id());
}
// Create a "Llama" content block.
$block_content = BlockContent::create([
'info' => 'Llama',
'type' => 'basic',
'body' => [
'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
'format' => 'plain_text',
],
])->setUnpublished();
$block_content->save();
return $block_content;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.