You are here

public function UserEventTest::testUserCancelMethodsAlterEventWithSet in Hook Event Dispatcher 8

User cancel methods alter event with set test.

File

tests/src/Unit/User/UserEventTest.php, line 81

Class

UserEventTest
Class UserEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\User

Code

public function testUserCancelMethodsAlterEventWithSet() {
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::USER_CANCEL_METHODS_ALTER => function (UserCancelMethodsAlterEvent $event) {
      $event
        ->setMethods([
        'New method',
      ]);
    },
  ]);
  $methods = [
    'Test method',
  ];
  hook_event_dispatcher_user_cancel_methods_alter($methods);

  /** @var \Drupal\hook_event_dispatcher\Event\User\UserCancelMethodsAlterEvent $event */
  $event = $this->manager
    ->getRegisteredEvent(HookEventDispatcherInterface::USER_CANCEL_METHODS_ALTER);
  self::assertSame([
    'New method',
  ], $event
    ->getMethods());
}