protected function ContentLockBlockTest::createBlockContent in Content locking (anti-concurrent editing) 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/ContentLockBlockTest.php \Drupal\Tests\content_lock\Functional\ContentLockBlockTest::createBlockContent()
Creates a custom block.
Parameters
bool|string $title: (optional) Title of block. When no value is given uses a random name. Defaults to FALSE.
string $bundle: (optional) Bundle name. Defaults to 'basic'.
bool $save: (optional) Whether to save the block. Defaults to TRUE.
Return value
\Drupal\block_content\Entity\BlockContent Created custom block.
1 call to ContentLockBlockTest::createBlockContent()
- ContentLockBlockTest::testContentLockBlock in tests/
src/ Functional/ ContentLockBlockTest.php - Test simultaneous edit on block.
File
- tests/
src/ Functional/ ContentLockBlockTest.php, line 44
Class
- ContentLockBlockTest
- Block tests.
Namespace
Drupal\Tests\content_lock\FunctionalCode
protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) {
$title = $title ?: $this
->randomMachineName();
$block_content = BlockContent::create([
'info' => $title,
'type' => $bundle,
'langcode' => 'en',
]);
if ($block_content && $save === TRUE) {
$block_content
->save();
}
return $block_content;
}