function MigrateBlockTest::assertEntity

Same name in this branch
  1. 9 core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\aggregator\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
  2. 9 core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
Same name in other branches
  1. 8.9.x core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
  2. 8.9.x core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockTest::assertEntity()
  3. 10 core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\forum\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
  4. 10 core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
  5. 10 core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockTest::assertEntity()
  6. 11.x core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\forum\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
  7. 11.x core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::assertEntity()
  8. 11.x core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockTest::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 MigrateBlockTest::assertEntity()
MigrateBlockTest::testBlockMigration in core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php
Tests the block migration.

File

core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php, line 87

Class

MigrateBlockTest
Tests migration of blocks to configuration entities.

Namespace

Drupal\Tests\block\Kernel\Migrate\d7

Code

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.