function ThemeNegotiatorTest::testDetermineActiveThemeWithNotApplyingNegotiator
Tests determining with two negotiators of which one does not apply.
See also
\Drupal\Core\Theme\ThemeNegotiatorInterface
File
- 
              core/
tests/ Drupal/ Tests/ Core/ Theme/ ThemeNegotiatorTest.php, line 174  
Class
- ThemeNegotiatorTest
 - @coversDefaultClass \Drupal\Core\Theme\ThemeNegotiator[[api-linebreak]] @group Theme
 
Namespace
Drupal\Tests\Core\ThemeCode
public function testDetermineActiveThemeWithNotApplyingNegotiator() {
  $negotiators = [];
  $negotiator = $this->createMock('Drupal\\Core\\Theme\\ThemeNegotiatorInterface');
  $negotiator->expects($this->never())
    ->method('determineActiveTheme');
  $negotiator->expects($this->once())
    ->method('applies')
    ->willReturn(FALSE);
  $negotiators['test_negotiator_1'] = $negotiator;
  $negotiator = $this->createMock('Drupal\\Core\\Theme\\ThemeNegotiatorInterface');
  $negotiator->expects($this->once())
    ->method('determineActiveTheme')
    ->willReturn('example_test2');
  $negotiator->expects($this->once())
    ->method('applies')
    ->willReturn(TRUE);
  $negotiators['test_negotiator_2'] = $negotiator;
  foreach ($negotiators as $id => $negotiator) {
    $this->container
      ->set($id, $negotiator);
  }
  $this->themeAccessCheck
    ->expects($this->any())
    ->method('checkAccess')
    ->willReturn(TRUE);
  $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
  $theme = $this->createThemeNegotiator(array_keys($negotiators))
    ->determineActiveTheme($route_match);
  $this->assertEquals('example_test2', $theme);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.