You are here

public function ThemeNegotiatorTest::testDetermineActiveThemeWithAccessCheck in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php \Drupal\Tests\Core\Theme\ThemeNegotiatorTest::testDetermineActiveThemeWithAccessCheck()

Tests determining with two negotiators of which just one returns access.

See also

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

File

core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php, line 114
Contains \Drupal\Tests\Core\Theme\ThemeNegotiatorTest.

Class

ThemeNegotiatorTest
@coversDefaultClass \Drupal\Core\Theme\ThemeNegotiator @group Theme

Namespace

Drupal\Tests\Core\Theme

Code

public function testDetermineActiveThemeWithAccessCheck() {
  $negotiator = $this
    ->getMock('Drupal\\Core\\Theme\\ThemeNegotiatorInterface');
  $negotiator
    ->expects($this
    ->once())
    ->method('determineActiveTheme')
    ->will($this
    ->returnValue('example_test'));
  $negotiator
    ->expects($this
    ->once())
    ->method('applies')
    ->will($this
    ->returnValue(TRUE));
  $this->themeNegotiator
    ->addNegotiator($negotiator, 10);
  $negotiator = $this
    ->getMock('Drupal\\Core\\Theme\\ThemeNegotiatorInterface');
  $negotiator
    ->expects($this
    ->once())
    ->method('determineActiveTheme')
    ->will($this
    ->returnValue('example_test2'));
  $negotiator
    ->expects($this
    ->once())
    ->method('applies')
    ->will($this
    ->returnValue(TRUE));
  $this->themeNegotiator
    ->addNegotiator($negotiator, 0);
  $this->themeAccessCheck
    ->expects($this
    ->at(0))
    ->method('checkAccess')
    ->with('example_test')
    ->will($this
    ->returnValue(FALSE));
  $this->themeAccessCheck
    ->expects($this
    ->at(1))
    ->method('checkAccess')
    ->with('example_test2')
    ->will($this
    ->returnValue(TRUE));
  $route_match = new RouteMatch('test_route', new Route('/test-route'), array(), array());
  $theme = $this->themeNegotiator
    ->determineActiveTheme($route_match);
  $this
    ->assertEquals('example_test2', $theme);
}