function FieldBlockTest::getTestBlock
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::getTestBlock()
- 8.9.x core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::getTestBlock()
- 11.x core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::getTestBlock()
Instantiates a block for testing.
Parameters
\Prophecy\Prophecy\ProphecyInterface $entity_prophecy: An entity prophecy for use as an entity context value.
array $configuration: A configuration array containing information about the plugin instance.
array $plugin_definition: The plugin implementation definition.
Return value
\Drupal\layout_builder\Plugin\Block\FieldBlock The block to test.
7 calls to FieldBlockTest::getTestBlock()
- FieldBlockTest::testBlockAccessEntityAllowedFieldHasValue in core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php - Tests populated vs empty build.
- FieldBlockTest::testBlockAccessEntityAllowedFieldNotAllowed in core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php - Tests field access.
- FieldBlockTest::testBlockAccessEntityAllowedNoField in core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php - Tests fieldable entity without a particular field.
- FieldBlockTest::testBlockAccessEntityAllowedNotFieldable in core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php - Tests unfieldable entity.
- FieldBlockTest::testBlockAccessEntityNotAllowed in core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php - Tests entity access.
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ FieldBlockTest.php, line 214
Class
- FieldBlockTest
- @coversDefaultClass \Drupal\layout_builder\Plugin\Block\FieldBlock @group Field
Namespace
Drupal\Tests\layout_builder\KernelCode
protected function getTestBlock(ProphecyInterface $entity_prophecy, array $configuration = [], array $plugin_definition = []) {
$entity_prophecy->getCacheContexts()
->willReturn([]);
$entity_prophecy->getCacheTags()
->willReturn([]);
$entity_prophecy->getCacheMaxAge()
->willReturn(0);
$plugin_definition += [
'provider' => 'test',
'default_formatter' => '',
'category' => 'Test',
'admin_label' => 'Test Block',
'bundles' => [
'entity_test',
],
'context_definitions' => [
'entity' => EntityContextDefinition::fromEntityTypeId('entity_test')->setLabel('Test'),
'view_mode' => new ContextDefinition('string'),
],
];
$formatter_manager = $this->prophesize(FormatterPluginManager::class);
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$block = new FieldBlock($configuration, 'field_block:entity_test:entity_test:the_field_name', $plugin_definition, $this->entityFieldManager
->reveal(), $formatter_manager->reveal(), $module_handler->reveal(), $this->logger
->reveal());
$block->setContextValue('entity', $entity_prophecy->reveal());
$block->setContextValue('view_mode', 'default');
return $block;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.