You are here

public function OtherEventVariablesTest::testViewFieldEvent in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventVariablesTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\OtherEventVariablesTest::testViewFieldEvent()

Test a ViewFieldPreprocessEvent.

File

modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventVariablesTest.php, line 192

Class

OtherEventVariablesTest
Class OtherEventVariablesTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testViewFieldEvent() : void {
  $variablesArray = $this
    ->createVariablesArray();
  $field = Mockery::mock(FieldHandlerInterface::class);
  $variablesArray['field'] = $field;
  $output = Mockery::mock(Markup::class);
  $variablesArray['output'] = $output;
  $row = Mockery::mock(ResultRow::class);
  $variablesArray['row'] = $row;
  $view = Mockery::mock(ViewExecutable::class);
  $variablesArray['view'] = $view;

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