You are here

public function MigrateBlockTest::assertEntity in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php \Drupal\block\Tests\Migrate\d6\MigrateBlockTest::assertEntity()
  2. 8 core/modules/block/src/Tests/Migrate/d7/MigrateBlockTest.php \Drupal\block\Tests\Migrate\d7\MigrateBlockTest::assertEntity()
Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Tests/Migrate/d7/MigrateBlockTest.php \Drupal\block\Tests\Migrate\d7\MigrateBlockTest::assertEntity()

Asserts various aspects of a block.

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.

string $weight: The block weight.

1 call to MigrateBlockTest::assertEntity()
MigrateBlockTest::testBlockMigration in core/modules/block/src/Tests/Migrate/d7/MigrateBlockTest.php
Tests the block migration.

File

core/modules/block/src/Tests/Migrate/d7/MigrateBlockTest.php, line 81
Contains \Drupal\block\Tests\Migrate\d7\MigrateBlockTest.

Class

MigrateBlockTest
Tests migration of blocks to configuration entities.

Namespace

Drupal\block\Tests\Migrate\d7

Code

public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight) {
  $block = Block::load($id);
  $this
    ->assertTrue($block instanceof Block);

  /** @var \Drupal\block\BlockInterface $block */
  $this
    ->assertIdentical($plugin_id, $block
    ->getPluginId());
  $visibility = $block
    ->getVisibility();
  if ($roles) {
    $this
      ->assertIdentical($roles, array_values($visibility['user_role']['roles']));
    $this
      ->assertIdentical('@user.current_user_context:current_user', $visibility['user_role']['context_mapping']['user']);
  }
  if ($pages) {
    $this
      ->assertIdentical($pages, $visibility['request_path']['pages']);
  }
  $this
    ->assertIdentical($region, $block
    ->getRegion());
  $this
    ->assertIdentical($theme, $block
    ->getTheme());
  $this
    ->assertIdentical($weight, $block
    ->getWeight());
}