You are here

protected function RadioactivityFunctionTestTrait::createEmitterViewDisplay in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x tests/src/Traits/RadioactivityFunctionTestTrait.php \Drupal\Tests\radioactivity\Traits\RadioactivityFunctionTestTrait::createEmitterViewDisplay()

Creates an emitter field formatter.

Parameters

string $fieldName: Field machine name.

int|float $energy: The energy to emit.

string $display: The field display type.

Return value

\Drupal\Core\Entity\Entity\EntityViewDisplay The entity view display object.

2 calls to RadioactivityFunctionTestTrait::createEmitterViewDisplay()
EmitTest::testCount in tests/src/FunctionalJavascript/EmitTest.php
Tests Radioactivity count functionality.
EmitTest::testUnpublished in tests/src/FunctionalJavascript/EmitTest.php
Validate that no energy is emitted if entity is unpublished.

File

tests/src/Traits/RadioactivityFunctionTestTrait.php, line 164

Class

RadioactivityFunctionTestTrait
Radioactivity functional test trait.

Namespace

Drupal\Tests\radioactivity\Traits

Code

protected function createEmitterViewDisplay($fieldName, $energy = 10, $display = 'raw') {
  $entity_view_display = EntityViewDisplay::create([
    'targetEntityType' => $this->entityType,
    'bundle' => $this->entityBundle,
    'mode' => 'default',
    'status' => TRUE,
  ]);
  $entity_view_display
    ->setComponent($fieldName, [
    'type' => 'radioactivity_emitter',
    'settings' => [
      'energy' => $energy,
      'display' => $display,
    ],
  ]);
  $entity_view_display
    ->save();
  return $entity_view_display;
}