public static function LayoutBuilderRestrictionsTestBase::generateTestBlocks in Layout Builder Restrictions 8.2
Generate 3 blocks from 2 different block types.
Return value
array A keyed array of the generated demo blocks with IDs.
9 calls to LayoutBuilderRestrictionsTestBase::generateTestBlocks()
- BlacklistedRestrictionsTest::testBlockRestriction in tests/
src/ FunctionalJavascript/ BlacklistedRestrictionsTest.php - Verify that the UI can restrict blocks in Layout Builder settings tray.
- BlockPlacementBlacklistTest::testBlockRestriction in modules/
layout_builder_restrictions_by_region/ tests/ src/ FunctionalJavascript/ BlockPlacementBlacklistTest.php - Verify that the UI can restrict blocks in Layout Builder settings tray.
- BlockPlacementWhitelistTest::testBlockRestriction in modules/
layout_builder_restrictions_by_region/ tests/ src/ FunctionalJavascript/ BlockPlacementWhitelistTest.php - Verify that the UI can restrict blocks in Layout Builder settings tray.
- DefaultRestrictionsTest::testNewCategoriesAllowed in tests/
src/ FunctionalJavascript/ DefaultRestrictionsTest.php - When new categories are allowed, a newly available block is allowed.
- DefaultRestrictionsTest::testNewCategoriesRestricted in tests/
src/ FunctionalJavascript/ DefaultRestrictionsTest.php - When new categories are restricted, a newly available block is restricted.
File
- tests/
src/ FunctionalJavascript/ LayoutBuilderRestrictionsTestBase.php, line 117
Class
- LayoutBuilderRestrictionsTestBase
- General-purpose methods for testing restrictions.
Namespace
Drupal\Tests\layout_builder_restrictions\FunctionalJavascriptCode
public static function generateTestBlocks() {
$bundle = BlockContentType::create([
'id' => 'basic',
'label' => 'Basic',
]);
$bundle
->save();
$bundle = BlockContentType::create([
'id' => 'alternate',
'label' => 'Alternate',
]);
$bundle
->save();
block_content_add_body_field($bundle
->id());
$blocks = [
'Basic Block 1' => 'basic',
'Basic Block 2' => 'basic',
'Alternate Block 1' => 'alternate',
];
foreach ($blocks as $info => $type) {
$block = BlockContent::create([
'info' => $info,
'type' => $type,
'body' => [
[
'value' => 'This is the block content',
'format' => filter_default_format(),
],
],
]);
$block
->save();
$blocks[$info] = $block
->uuid();
}
return $blocks;
}