You are here

public function BlockEventTest::testBlockBuildAlterEvent in Hook Event Dispatcher 8

Test the BlockBuildAlterEvent.

File

tests/src/Unit/Block/BlockEventTest.php, line 41

Class

BlockEventTest
Class BlockEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Block

Code

public function testBlockBuildAlterEvent() {
  $build = [
    'test' => 'build',
  ];
  $block = $this
    ->createMock(BlockPluginInterface::class);
  hook_event_dispatcher_block_build_alter($build, $block);

  /** @var \Drupal\hook_event_dispatcher\Event\Block\BlockBuildAlterEvent $event */
  $event = $this->manager
    ->getRegisteredEvent(HookEventDispatcherInterface::BLOCK_BUILD_ALTER);
  self::assertEquals($build, $event
    ->getBuild());
  self::assertEquals($block, $event
    ->getBlock());
  $newBuild = [
    'newBuild',
  ];
  $event
    ->setBuild($newBuild);
  self::assertEquals($newBuild, $event
    ->getBuild());
}