public function UserEventTest::testUserCancelMethodsAlterEvent in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/user_event_dispatcher/tests/src/Unit/User/UserEventTest.php \Drupal\Tests\user_event_dispatcher\Unit\User\UserEventTest::testUserCancelMethodsAlterEvent()
User cancel methods alter event test.
Plugin annotation
@SuppressWarnings(PHPMD . UnusedLocalVariable);
File
- modules/
user_event_dispatcher/ tests/ src/ Unit/ User/ UserEventTest.php, line 67
Class
- UserEventTest
- Class UserEventTest.
Namespace
Drupal\Tests\user_event_dispatcher\Unit\UserCode
public function testUserCancelMethodsAlterEvent() : void {
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::USER_CANCEL_METHODS_ALTER => static function (UserCancelMethodsAlterEvent $event) {
$name =& $event
->getMethods()[0];
$name .= ' improved!';
},
]);
$methods = [
'Test method',
];
$expectedMethods = [
'Test method improved!',
];
user_event_dispatcher_user_cancel_methods_alter($methods);
/** @var \Drupal\user_event_dispatcher\Event\User\UserCancelMethodsAlterEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::USER_CANCEL_METHODS_ALTER);
self::assertSame($expectedMethods, $methods);
self::assertSame($expectedMethods, $event
->getMethods());
}