function ConfigActionsTest::testEntityMethodActions

Tests the application of entity method actions on a block.

File

core/modules/block/tests/src/Kernel/ConfigActionsTest.php, line 55

Class

ConfigActionsTest
@covers \Drupal\block\Plugin\ConfigAction\PlaceBlock[[api-linebreak]] @covers \Drupal\block\Plugin\ConfigAction\PlaceBlockDeriver[[api-linebreak]] @group block

Namespace

Drupal\Tests\block\Kernel

Code

public function testEntityMethodActions() : void {
  $block = $this->placeBlock('system_messages_block', [
    'theme' => 'olivero',
  ]);
  $this->assertSame('content', $block->getRegion());
  $this->assertSame(0, $block->getWeight());
  $this->configActionManager
    ->applyAction('entity_method:block.block:setRegion', $block->getConfigDependencyName(), 'highlighted');
  $this->configActionManager
    ->applyAction('entity_method:block.block:setWeight', $block->getConfigDependencyName(), -10);
  $block = Block::load($block->id());
  $this->assertSame('highlighted', $block->getRegion());
  $this->assertSame(-10, $block->getWeight());
}

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