Commit be4177a9 authored by catch's avatar catch
Browse files

Issue #3084078 by lauriii, alexpott, Jaesin:...

Issue #3084078 by lauriii, alexpott, Jaesin: AdminNegotiator::determineActiveTheme() does not adhere to the interface
parent 3bcb7297
......@@ -72,7 +72,7 @@ public function applies(RouteMatchInterface $route_match) {
* {@inheritdoc}
*/
public function determineActiveTheme(RouteMatchInterface $route_match) {
return $this->configFactory->get('system.theme')->get('admin');
return $this->configFactory->get('system.theme')->get('admin') ?: NULL;
}
}
<?php
namespace Drupal\Tests\user\Unit\Theme;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Routing\RouteMatch;
use Drupal\Core\Session\AccountInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\user\Theme\AdminNegotiator;
/**
* Tests AdminNegotiator class.
*
* @group user
* @coversDefaultClass \Drupal\user\Theme\AdminNegotiator
*/
class AdminNegotiatorTest extends UnitTestCase {
/**
* @dataProvider getThemes
*/
public function testDetermineActiveTheme($admin_theme, $expected) {
$user = $this->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],
];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment