diff --git a/core/modules/user/src/Theme/AdminNegotiator.php b/core/modules/user/src/Theme/AdminNegotiator.php index 3c3ecd6fae4..398acbd2013 100644 --- a/core/modules/user/src/Theme/AdminNegotiator.php +++ b/core/modules/user/src/Theme/AdminNegotiator.php @@ -72,7 +72,7 @@ class AdminNegotiator implements ThemeNegotiatorInterface { * {@inheritdoc} */ public function determineActiveTheme(RouteMatchInterface $route_match) { - return $this->configFactory->get('system.theme')->get('admin'); + return $this->configFactory->get('system.theme')->get('admin') ?: NULL; } } diff --git a/core/modules/user/tests/src/Unit/Theme/AdminNegotiatorTest.php b/core/modules/user/tests/src/Unit/Theme/AdminNegotiatorTest.php new file mode 100644 index 00000000000..ddbba3aa52e --- /dev/null +++ b/core/modules/user/tests/src/Unit/Theme/AdminNegotiatorTest.php @@ -0,0 +1,44 @@ +prophesize(AccountInterface::class); + $config_factory = $this->getConfigFactoryStub(['system.theme' => ['admin' => $admin_theme]]); + $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class); + $admin_context = $this->prophesize(AdminContext::class); + $negotiator = new AdminNegotiator($user->reveal(), $config_factory, $entity_type_manager->reveal(), $admin_context->reveal()); + $route_match = $this->prophesize(RouteMatch::class); + $this->assertSame($expected, $negotiator->determineActiveTheme($route_match->reveal())); + } + + /** + * Provides a list of theme names to test. + */ + public function getThemes() { + return [ + ['seven', 'seven'], + [NULL, NULL], + ['', NULL], + ]; + } + +}