You are here

public function EntityEventVariablesTest::testEckEntityEvent in Hook Event Dispatcher 8

Test a EckEntityPreprocessEvent.

File

tests/src/Unit/Preprocess/EntityEventVariablesTest.php, line 67

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

public function testEckEntityEvent() {
  $eckEntity = new EntityMock('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\hook_event_dispatcher\Event\Preprocess\Variables\EckEntityEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(EckEntityPreprocessEvent::class, $variablesArray);
  $this
    ->assertInstanceOf(EckEntityEventVariables::class, $variables);
  $this
    ->assertAbstractEntityEventVariables($variables, $eckEntity);
  $this
    ->assertSame($eckEntity, $variables
    ->getEckEntity());
}