You are here

public function ContextHandlerTest::testApplyContextMappingConfigurableAssignedMiss in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php \Drupal\Tests\Core\Plugin\ContextHandlerTest::testApplyContextMappingConfigurableAssignedMiss()

@covers ::applyContextMapping

@expectedException \Drupal\Component\Plugin\Exception\ContextException @expectedExceptionMessage Assigned contexts were not satisfied: miss

File

core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php, line 471
Contains \Drupal\Tests\Core\Plugin\ContextHandlerTest.

Class

ContextHandlerTest
@coversDefaultClass \Drupal\Core\Plugin\Context\ContextHandler @group Plugin

Namespace

Drupal\Tests\Core\Plugin

Code

public function testApplyContextMappingConfigurableAssignedMiss() {
  $context = $this
    ->getMock('Drupal\\Core\\Plugin\\Context\\ContextInterface');
  $context
    ->expects($this
    ->never())
    ->method('getContextValue');
  $contexts = array(
    'name' => $context,
  );
  $context_definition = $this
    ->getMock('Drupal\\Core\\Plugin\\Context\\ContextDefinitionInterface');
  $plugin = $this
    ->getMock('Drupal\\Tests\\Core\\Plugin\\TestConfigurableContextAwarePluginInterface');
  $plugin
    ->expects($this
    ->once())
    ->method('getContextMapping')
    ->willReturn([]);
  $plugin
    ->expects($this
    ->once())
    ->method('getContextDefinitions')
    ->will($this
    ->returnValue(array(
    'hit' => $context_definition,
  )));
  $plugin
    ->expects($this
    ->never())
    ->method('setContextValue');
  $this->contextHandler
    ->applyContextMapping($plugin, $contexts, [
    'miss' => 'name',
  ]);
}