function ThemeNegotiatorTest::testDetermineActiveTheme

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php \Drupal\Tests\Core\Theme\ThemeNegotiatorTest::testDetermineActiveTheme()
  2. 10 core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php \Drupal\Tests\Core\Theme\ThemeNegotiatorTest::testDetermineActiveTheme()
  3. 11.x core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php \Drupal\Tests\Core\Theme\ThemeNegotiatorTest::testDetermineActiveTheme()

Tests determining the theme.

See also

\Drupal\Core\Theme\ThemeNegotiator::determineActiveTheme()

File

core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php, line 61

Class

ThemeNegotiatorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Theme%21ThemeNegotiator.php/class/ThemeNegotiator/9" title="Provides a class which determines the active theme of the page." class="local">\Drupal\Core\Theme\ThemeNegotiator</a> @group Theme

Namespace

Drupal\Tests\Core\Theme

Code

public function testDetermineActiveTheme() {
    $negotiator = $this->createMock('Drupal\\Core\\Theme\\ThemeNegotiatorInterface');
    $negotiator->expects($this->once())
        ->method('determineActiveTheme')
        ->willReturn('example_test');
    $negotiator->expects($this->once())
        ->method('applies')
        ->willReturn(TRUE);
    $this->container
        ->set('test_negotiator', $negotiator);
    $negotiators = [
        'test_negotiator',
    ];
    $this->themeAccessCheck
        ->expects($this->any())
        ->method('checkAccess')
        ->willReturn(TRUE);
    $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
    $theme = $this->createThemeNegotiator($negotiators)
        ->determineActiveTheme($route_match);
    $this->assertEquals('example_test', $theme);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.