class BlockContentTest
Same name and namespace in other branches
- 11.x core/modules/block_content/tests/src/Kernel/BlockContentTest.php \Drupal\Tests\block_content\Kernel\BlockContentTest
Tests the block content.
@group block_content
Hierarchy
- class \Drupal\Tests\block_content\Kernel\BlockContentTest
Expanded class hierarchy of BlockContentTest
File
-
core/
modules/ block_content/ tests/ src/ Kernel/ BlockContentTest.php, line 20
Namespace
Drupal\Tests\block_content\KernelView source
class BlockContentTest extends KernelTestBase {
use UserCreationTrait;
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'block_content',
'system',
'user',
];
/**
* {@inheritdoc}
*/
public function setUp() : void {
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('block_content');
}
/**
* Tests the editing links for BlockContentBlock.
*/
public function testOperationLinks() : void {
// Create a 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%",
])->save();
// And a block content entity.
$block_content = BlockContent::create([
'info' => 'Spiffy prototype',
'type' => 'spiffy',
]);
$block_content->save();
$block = Block::create([
'plugin' => 'block_content' . PluginBase::DERIVATIVE_SEPARATOR . $block_content->uuid(),
'region' => 'content',
'id' => 'machine_name',
'theme' => 'stark',
]);
// The anonymous user doesn't have the "administer block" permission.
$this->assertEmpty(block_content_entity_operation($block));
$this->setUpCurrentUser([
'uid' => 1,
], [
'edit any spiffy block content',
'administer blocks',
]);
// The admin user does have the "administer block" permission.
$this->assertEquals([
'block-edit' => [
'title' => $this->t('Edit block'),
'url' => $block_content->toUrl('edit-form')
->setOptions([]),
'weight' => 50,
],
], block_content_entity_operation($block));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
BlockContentTest::$modules | protected static | property | Modules to install. |
BlockContentTest::setUp | public | function | |
BlockContentTest::testOperationLinks | public | function | Tests the editing links for BlockContentBlock. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.