expectException( MiddlewareException::class ); $scope = ExtensionRegistry::getInstance()->setAttributeForTest( 'NotificationMiddleware', [ [ "factory" => static function () { return new class implements NotificationMiddlewareInterface { public function handle( $batch, callable $next ): void { MediaWikiServices::getInstance() ->getNotificationService() ->notify( new Notification( "bad" ), new RecipientSet( [] ) ); $next(); } }; }, ], ] ); $sut = MediaWikiServices::getInstance()->getNotificationService(); $user = $this->createMock( UserIdentity::class ); $sut->notify( new Notification( "good" ), new RecipientSet( [ $user ] ) ); ScopedCallback::consume( $scope ); } }