You are here

public function EntityEventVariablesTest::testEckEntityEvent in Hook Event Dispatcher 3.x

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

Test a EckEntityPreprocessEvent.

File

modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php, line 76

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testEckEntityEvent() : void {
  $eckEntity = EntityMockFactory::getMock(EckEntityInterface::class, 'eck_entity', 'eck_entity_bundle', 'eck_entity_view_mode');
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['eck_entity'] = $eckEntity;
  $variablesArray['elements'] = [
    '#view_mode' => $eckEntity
      ->getViewMode(),
  ];
  $variablesArray['theme_hook_original'] = $eckEntity
    ->getEntityType();
  $variablesArray['bundle'] = $eckEntity
    ->bundle();

  /** @var \Drupal\preprocess_event_dispatcher\Variables\EckEntityEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(EckEntityPreprocessEvent::class, $variablesArray);
  self::assertInstanceOf(EckEntityEventVariables::class, $variables);
  $this
    ->assertAbstractEntityEventVariables($variables, $eckEntity);
  self::assertSame($eckEntity, $variables
    ->getEckEntity());
}