You are here

public function OtherEventVariablesTest::testViewFieldEvent in Hook Event Dispatcher 8

Test a ViewFieldPreprocessEvent.

File

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

Class

OtherEventVariablesTest
Class OtherEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

public function testViewFieldEvent() {
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['field'] = 'field';
  $variablesArray['output'] = 'output';
  $variablesArray['row'] = 'row';
  $variablesArray['view'] = 'view';

  /** @var \Drupal\hook_event_dispatcher\Event\Preprocess\Variables\ViewFieldEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(ViewFieldPreprocessEvent::class, $variablesArray);
  self::assertInstanceOf(ViewFieldEventVariables::class, $variables);
  $this
    ->assertAbstractEventVariables($variables);
  self::assertEquals('field', $variables
    ->getField());
  self::assertEquals('output', $variables
    ->getOutput());
  self::assertEquals('row', $variables
    ->getRow());
  self::assertEquals('view', $variables
    ->getView());
}