function BlockContentCreationTest::getBlockByLabel
Same name in other branches
- 10 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::getBlockByLabel()
Load a block based on the label.
4 calls to BlockContentCreationTest::getBlockByLabel()
- BlockContentCreationTest::testBlockContentCreation in core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php - Creates a "Basic block" block and verifies its consistency in the database.
- BlockContentCreationTest::testBlockContentCreationMultipleViewModes in core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php - Creates a "Basic page" block with multiple view modes.
- BlockContentCreationTest::testBlockContentFormSubmitHandlers in core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php - Tests the redirect workflow of creating a block_content and block.
- BlockContentCreationTest::testDefaultBlockContentCreation in core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php - Create a default content block.
File
-
core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php, line 333
Class
- BlockContentCreationTest
- Create a block and test saving it.
Namespace
Drupal\Tests\block_content\FunctionalCode
private function getBlockByLabel(string $label) : ?BlockContentInterface {
$blocks = \Drupal::entityTypeManager()->getStorage('block_content')
->loadByProperties([
'info' => $label,
]);
if (empty($blocks)) {
return NULL;
}
return reset($blocks);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.