You are here

public function OtherEventVariablesTest::testFieldEvent in Hook Event Dispatcher 8

Test a FieldPreprocessEvent.

File

tests/src/Unit/Preprocess/OtherEventVariablesTest.php, line 80

Class

OtherEventVariablesTest
Class OtherEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

public function testFieldEvent() {
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['element'] = [
    'element array',
  ];
  $variablesArray['items'] = [
    'items array',
  ];

  /** @var \Drupal\hook_event_dispatcher\Event\Preprocess\Variables\FieldEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(FieldPreprocessEvent::class, $variablesArray);
  self::assertInstanceOf(FieldEventVariables::class, $variables);
  $this
    ->assertAbstractEventVariables($variables);
  self::assertEquals([
    'element array',
  ], $variables
    ->getElement());
  self::assertEquals([
    'items array',
  ], $variables
    ->getItems());
}