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/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\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.

array $visibility: The block visibility settings.

string $region: The display region.

string $theme: The theme.

int $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 80

Class

MigrateBlockTest
Tests migration of blocks to configuration entities.

Namespace

Drupal\Tests\block\Kernel\Migrate\d6

Code

public function assertEntity(string $id, array $visibility, string $region, string $theme, int $weight, array $settings = NULL, bool $status = TRUE) : void {
    $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);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.