function MigrateBlockNoBlockContentTest::assertEntity
Same name in other branches
- 10 core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockNoBlockContentTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockNoBlockContentTest::assertEntity()
Asserts various aspects of a block.
@internal
Parameters
string $id: The block ID.
string $plugin_id: The block's plugin ID.
array $roles: Role IDs the block is expected to have.
string $pages: The list of pages on which the block should appear.
string $region: The display region.
string $theme: The theme.
int $weight: The block weight.
string $label: The block label.
string $label_display: The block label display setting.
bool $status: Whether the block is expected to be enabled or disabled.
1 call to MigrateBlockNoBlockContentTest::assertEntity()
- MigrateBlockNoBlockContentTest::testBlockMigration in core/
modules/ block/ tests/ src/ Kernel/ Migrate/ d7/ MigrateBlockNoBlockContentTest.php - Tests the block migration.
File
-
core/
modules/ block/ tests/ src/ Kernel/ Migrate/ d7/ MigrateBlockNoBlockContentTest.php, line 84
Class
- MigrateBlockNoBlockContentTest
- Tests the migration of blocks without Block Content installed.
Namespace
Drupal\Tests\block\Kernel\Migrate\d7Code
public function assertEntity(string $id, string $plugin_id, array $roles, string $pages, string $region, string $theme, int $weight, string $label, string $label_display, bool $status = TRUE) : void {
$block = Block::load($id);
$this->assertInstanceOf(Block::class, $block);
/** @var \Drupal\block\BlockInterface $block */
$this->assertSame($plugin_id, $block->getPluginId());
$visibility = $block->getVisibility();
if ($roles) {
$this->assertSame($roles, array_values($visibility['user_role']['roles']));
$this->assertSame('@user.current_user_context:current_user', $visibility['user_role']['context_mapping']['user']);
}
if ($pages) {
$this->assertSame($pages, $visibility['request_path']['pages']);
}
$this->assertSame($region, $block->getRegion());
$this->assertSame($theme, $block->getTheme());
$this->assertSame($weight, $block->getWeight());
$this->assertSame($status, $block->status());
$config = $this->config('block.block.' . $id);
$this->assertSame($label, $config->get('settings.label'));
$this->assertSame($label_display, $config->get('settings.label_display'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.