You are here

public function EnergyBelowCutoffTest::testBundleCreatedEvent in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x tests/src/Unit/EnergyBelowCutoffTest.php \Drupal\Tests\radioactivity\Unit\EnergyBelowCutoffTest::testBundleCreatedEvent()

Tests the event metadata.

File

tests/src/Unit/EnergyBelowCutoffTest.php, line 18

Class

EnergyBelowCutoffTest
Checks that the event "radioactivity_field_cutoff" is correctly defined.

Namespace

Drupal\Tests\radioactivity\Unit

Code

public function testBundleCreatedEvent() {
  $plugin_definition = $this->eventManager
    ->getDefinition('radioactivity_field_cutoff');
  $this
    ->assertSame('Energy is below the cutoff level', (string) $plugin_definition['label']);
  $event = $this->eventManager
    ->createInstance('radioactivity_field_cutoff');
  $entity_context_definition = $event
    ->getContextDefinition('entity');
  $this
    ->assertSame('entity', $entity_context_definition
    ->getDataType());
  $this
    ->assertSame('Entity', $entity_context_definition
    ->getLabel());
}