You are here

public function ContextHandlerTest::testFilterPluginDefinitionsByContexts 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::testFilterPluginDefinitionsByContexts()

@covers ::filterPluginDefinitionsByContexts

@dataProvider providerTestFilterPluginDefinitionsByContexts

File

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

Class

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

Namespace

Drupal\Tests\Core\Plugin

Code

public function testFilterPluginDefinitionsByContexts($has_context, $definitions, $expected) {
  if ($has_context) {
    $context = $this
      ->getMock('Drupal\\Core\\Plugin\\Context\\ContextInterface');
    $expected_context_definition = (new ContextDefinition('expected_data_type'))
      ->setConstraints(array(
      'expected_constraint_name' => 'expected_constraint_value',
    ));
    $context
      ->expects($this
      ->atLeastOnce())
      ->method('getContextDefinition')
      ->will($this
      ->returnValue($expected_context_definition));
    $contexts = array(
      $context,
    );
  }
  else {
    $contexts = array();
  }
  $this
    ->assertSame($expected, $this->contextHandler
    ->filterPluginDefinitionsByContexts($contexts, $definitions));
}