-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #3084078 by lauriii, alexpott, Jaesin: AdminNegotiator::determi…
…neActiveTheme() does not adhere to the interface (cherry picked from commit be4177a92ec00901f55e18198113a4ee1ef0ffa9)
- Loading branch information
catch
committed
Apr 24, 2020
1 parent
c61c700
commit 67e04b6
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?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], | ||
]; | ||
} | ||
|
||
} |