function ConfigActionsTest::testPlaceBlockInEmptyRegion

Tests using the PlaceBlock action in an empty region.

File

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

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 testPlaceBlockInEmptyRegion() : void {
  /** @var \Drupal\Core\Entity\Query\QueryInterface $query */
  $query = $this->container
    ->get(EntityTypeManagerInterface::class)
    ->getStorage('block')
    ->getQuery()
    ->count()
    ->condition('theme', 'olivero')
    ->condition('region', 'footer_top');
  $this->assertSame(0, $query->execute());
  // Place a block in that region.
  $this->configActionManager
    ->applyAction('placeBlockInDefaultTheme', 'block.block.test', [
    'plugin' => 'system_powered_by_block',
    'region' => [
      'olivero' => 'footer_top',
    ],
    'position' => 'first',
  ]);
  $this->assertSame(1, $query->execute());
}

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