function BlockContentEntityReferenceSelectionTest::setUp
Same name in other branches
- 8.9.x core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php \Drupal\Tests\block_content\Kernel\BlockContentEntityReferenceSelectionTest::setUp()
- 10 core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php \Drupal\Tests\block_content\Kernel\BlockContentEntityReferenceSelectionTest::setUp()
- 11.x core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php \Drupal\Tests\block_content\Kernel\BlockContentEntityReferenceSelectionTest::setUp()
Overrides KernelTestBase::setUp
File
-
core/
modules/ block_content/ tests/ src/ Kernel/ BlockContentEntityReferenceSelectionTest.php, line 68
Class
- BlockContentEntityReferenceSelectionTest
- Tests EntityReference selection handlers don't return non-reusable blocks.
Namespace
Drupal\Tests\block_content\KernelCode
public function setUp() : void {
parent::setUp();
$this->installSchema('system', [
'sequences',
]);
$this->installEntitySchema('user');
$this->installEntitySchema('block_content');
// Create a block content type.
$block_content_type = BlockContentType::create([
'id' => 'spiffy',
'label' => 'Mucho spiffy',
'description' => "Provides a block type that increases your site's spiffiness by up to 11%",
]);
$block_content_type->save();
$this->entityTypeManager = $this->container
->get('entity_type.manager');
// And reusable block content entities.
$this->blockReusable = BlockContent::create([
'info' => 'Reusable Block',
'type' => 'spiffy',
]);
$this->blockReusable
->save();
$this->blockNonReusable = BlockContent::create([
'info' => 'Non-reusable Block',
'type' => 'spiffy',
'reusable' => FALSE,
]);
$this->blockNonReusable
->save();
$configuration = [
'target_type' => 'block_content',
'target_bundles' => [
'spiffy' => 'spiffy',
],
'sort' => [
'field' => '_none',
],
];
$this->selectionHandler = new TestSelection($configuration, '', '', $this->container
->get('entity_type.manager'), $this->container
->get('module_handler'), \Drupal::currentUser(), \Drupal::service('entity_field.manager'), \Drupal::service('entity_type.bundle.info'), \Drupal::service('entity.repository'));
// Setup the 3 expectation cases.
$this->expectations = [
'both_blocks' => [
'spiffy' => [
$this->blockReusable
->id() => $this->blockReusable
->label(),
$this->blockNonReusable
->id() => $this->blockNonReusable
->label(),
],
],
'block_reusable' => [
'spiffy' => [
$this->blockReusable
->id() => $this->blockReusable
->label(),
],
],
'block_non_reusable' => [
'spiffy' => [
$this->blockNonReusable
->id() => $this->blockNonReusable
->label(),
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.