diff --git a/src/EventSubscriber/R4032LoginSubscriber.php b/src/EventSubscriber/R4032LoginSubscriber.php index 6f9b5f1..09ea25b 100644 --- a/src/EventSubscriber/R4032LoginSubscriber.php +++ b/src/EventSubscriber/R4032LoginSubscriber.php @@ -160,7 +160,7 @@ class R4032LoginSubscriber extends HttpExceptionSubscriberBase { if ($this->currentUser->isAnonymous() && $config->get('display_denied_message')) { $message = $config->get('access_denied_message'); $messageType = $config->get('access_denied_message_type'); - drupal_set_message(Xss::filterAdmin($message), $messageType); + \Drupal::messenger()->addMessage(Xss::filterAdmin($message), $messageType); } if ($redirectPath === '') { diff --git a/tests/src/Unit/R4032LoginSubscriberTest.php b/tests/src/Unit/R4032LoginSubscriberTest.php index e06bd2a..23ac3b3 100644 --- a/tests/src/Unit/R4032LoginSubscriberTest.php +++ b/tests/src/Unit/R4032LoginSubscriberTest.php @@ -80,7 +80,7 @@ namespace Drupal\Tests\r4032login\Unit { * {@inheritdoc} */ protected function setUp() { - $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $this->kernel = $this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface'); $this->configFactory = $this->getConfigFactoryStub([ 'r4032login.settings' => [ 'display_denied_message' => TRUE, @@ -92,20 +92,20 @@ namespace Drupal\Tests\r4032login\Unit { 'match_noredirect_pages' => '', ], ]); - $this->currentUser = $this->getMock('Drupal\Core\Session\AccountInterface'); + $this->currentUser = $this->createMock('Drupal\Core\Session\AccountInterface'); $this->requestStack = new RequestStack(); $this->requestStack->push(new Request()); - $this->pathMatcher = $this->getMock('\Drupal\Core\Path\PathMatcherInterface'); - $this->eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->pathMatcher = $this->createMock('\Drupal\Core\Path\PathMatcherInterface'); + $this->eventDispatcher = $this->createMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->urlAssembler = $this->getMock('Drupal\Core\Utility\UnroutedUrlAssemblerInterface'); + $this->urlAssembler = $this->createMock('Drupal\Core\Utility\UnroutedUrlAssemblerInterface'); $this->urlAssembler->expects($this->any())->method('assemble')->will($this->returnArgument(0)); - $this->router = $this->getMock('Drupal\Tests\Core\Routing\TestRouterInterface'); + $this->router = $this->createMock('Drupal\Tests\Core\Routing\TestRouterInterface'); $container = new ContainerBuilder(); - $container->set('path.validator', $this->getMock('Drupal\Core\Path\PathValidatorInterface')); + $container->set('path.validator', $this->createMock('Drupal\Core\Path\PathValidatorInterface')); $container->set('router.no_access_checks', $this->router); $container->set('unrouted_url_assembler', $this->urlAssembler); \Drupal::setContainer($container); @@ -253,13 +253,13 @@ namespace Drupal\Tests\r4032login\Unit { * An array of GetResponseForExceptionEvent exception events. */ public function providerInvalidExceptions() { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this-> createMock('Symfony\Component\HttpKernel\HttpKernelInterface'); $exceptions = []; foreach (get_declared_classes() as $name) { $class = new \ReflectionClass($name); if ($class->isSubclassOf('Exception')) { $exceptions[] = [ - new GetResponseForExceptionEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $this->getMockBuilder($name)->disableOriginalConstructor()->getMock()), + new GetResponseForExceptionEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $this->createMock($name)->disableOriginalConstructor()->getMock()), ]; } }