function BlockContentAccessHandlerTest::setUp
Same name in other branches
- 9 core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php \Drupal\Tests\block_content\Kernel\BlockContentAccessHandlerTest::setUp()
- 8.9.x core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php \Drupal\Tests\block_content\Kernel\BlockContentAccessHandlerTest::setUp()
- 11.x core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php \Drupal\Tests\block_content\Kernel\BlockContentAccessHandlerTest::setUp()
Overrides KernelTestBase::setUp
File
-
core/
modules/ block_content/ tests/ src/ Kernel/ BlockContentAccessHandlerTest.php, line 66
Class
- BlockContentAccessHandlerTest
- Tests the block content entity access handler.
Namespace
Drupal\Tests\block_content\KernelCode
protected function setUp() : void {
parent::setUp();
$this->installSchema('user', [
'users_data',
]);
$this->installEntitySchema('user');
$this->installEntitySchema('block_content');
// Create a basic block content type.
$block_content_type = BlockContentType::create([
'id' => 'basic',
'label' => 'A basic block type',
'description' => "Provides a block type that is basic.",
]);
$block_content_type->save();
// Create a square block content type.
$block_content_type = BlockContentType::create([
'id' => 'square',
'label' => 'A square block type',
'description' => "Provides a block type that is square.",
]);
$block_content_type->save();
$this->blockEntity = BlockContent::create([
'info' => 'The Block',
'type' => 'square',
]);
$this->blockEntity
->save();
// Create user 1 test does not have all permissions.
User::create([
'name' => 'admin',
])->save();
$this->role = Role::create([
'id' => 'test',
'label' => 'test role',
]);
$this->role
->save();
$this->accessControlHandler = new BlockContentAccessControlHandler(\Drupal::entityTypeManager()->getDefinition('block_content'), \Drupal::service('event_dispatcher'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.