You are here

public function MigrateBlockTest::assertEntity in Drupal 8

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

Asserts various aspects of a block.

Parameters

string $id: The block ID.

array $visibility: The block visibility settings.

string $region: The display region.

string $theme: The theme.

string $weight: The block weight.

array $settings: (optional) The block settings.

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/d6/MigrateBlockTest.php
Tests the block migration.

File

core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php, line 79

Class

MigrateBlockTest
Tests migration of blocks to configuration entities.

Namespace

Drupal\Tests\block\Kernel\Migrate\d6

Code

public function assertEntity($id, $visibility, $region, $theme, $weight, array $settings = NULL, $status = TRUE) {
  $block = Block::load($id);
  $this
    ->assertInstanceOf(Block::class, $block);
  $this
    ->assertSame($visibility, $block
    ->getVisibility());
  $this
    ->assertSame($region, $block
    ->getRegion());
  $this
    ->assertSame($theme, $block
    ->getTheme());
  $this
    ->assertSame($weight, $block
    ->getWeight());
  $this
    ->assertSame($status, $block
    ->status());
  if ($settings) {
    $block_settings = $block
      ->get('settings');
    $block_settings['id'] = current(explode(':', $block_settings['id']));
    $this
      ->assertEquals($settings, $block_settings);
  }
}