You are here

class ContextDefinitionTest in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/KernelTests/Core/Plugin/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\ContextDefinitionTest
  2. 10 core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php \Drupal\Tests\Core\Plugin\Context\ContextDefinitionTest
  3. 10 core/tests/Drupal/KernelTests/Core/Plugin/Annotation/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\Annotation\ContextDefinitionTest
Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Plugin/Annotation/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\Annotation\ContextDefinitionTest
  2. 9 core/tests/Drupal/KernelTests/Core/Plugin/Annotation/ContextDefinitionTest.php \Drupal\KernelTests\Core\Plugin\Annotation\ContextDefinitionTest

@coversDefaultClass \Drupal\Core\Annotation\ContextDefinition @group Plugin

Hierarchy

  • class \Drupal\KernelTests\Core\Plugin\Annotation\ContextDefinitionTest extends \Drupal\KernelTests\KernelTestBase

Expanded class hierarchy of ContextDefinitionTest

File

core/tests/Drupal/KernelTests/Core/Plugin/Annotation/ContextDefinitionTest.php, line 12

Namespace

Drupal\KernelTests\Core\Plugin\Annotation
View source
class ContextDefinitionTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'block_test',
  ];

  /**
   * Tests adding constraints via annotations.
   */
  public function testConstraints() {
    $definition = $this->container
      ->get('plugin.manager.block')
      ->getDefinition('test_context_aware');
    $this
      ->assertArrayHasKey('context_definitions', $definition);
    $this
      ->assertArrayHasKey('user', $definition['context_definitions']);
    $this
      ->assertInstanceOf(ContextDefinition::class, $definition['context_definitions']['user']);
    $this
      ->assertEquals([
      'NotNull' => [],
    ], $definition['context_definitions']['user']
      ->getConstraints());
    $this
      ->assertEquals("User Context", $definition['context_definitions']['user']
      ->getLabel());
  }

}

Members