You are here

public function OtherEventVariablesTest::testViewEvent in Hook Event Dispatcher 3.x

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

Test a ViewPreprocessEvent.

File

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

Class

OtherEventVariablesTest
Class OtherEventVariablesTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testViewEvent() : void {
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['rows'] = [
    [
      '#rows' => [
        'rows',
      ],
    ],
  ];
  $view = Mockery::mock(ViewExecutable::class);
  $variablesArray['view'] = $view;

  /** @var \Drupal\preprocess_event_dispatcher\Variables\ViewEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(ViewPreprocessEvent::class, $variablesArray);
  self::assertInstanceOf(ViewEventVariables::class, $variables);
  $this
    ->assertAbstractEventVariables($variables);
  self::assertSame([
    'rows',
  ], $variables
    ->getRows());
  self::assertSame($view, $variables
    ->getView());
}