You are here

public function OtherEventVariablesTest::testViewEvent in Hook Event Dispatcher 8

Test a ViewPreprocessEvent.

File

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

Class

OtherEventVariablesTest
Class OtherEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

public function testViewEvent() {
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['rows'][0]['#rows'] = [
    'rows',
  ];
  $variablesArray['view'] = 'view';

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