You are here

public function EntityEventVariablesTest::testTaxonomyTermEvent 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::testTaxonomyTermEvent()

Test a TaxonomyTermPreprocessEvent.

File

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

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testTaxonomyTermEvent() : void {
  $term = EntityMockFactory::getMock(TermInterface::class, 'taxonomy_term', 'term_bundle', 'term_view_mode');
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['term'] = $term;
  $variablesArray['theme_hook_original'] = $term
    ->getEntityType();
  $variablesArray['view_mode'] = $term
    ->getViewMode();

  /** @var \Drupal\preprocess_event_dispatcher\Variables\TaxonomyTermEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(TaxonomyTermPreprocessEvent::class, $variablesArray);
  self::assertInstanceOf(TaxonomyTermEventVariables::class, $variables);
  $this
    ->assertAbstractEntityEventVariables($variables, $term);
  self::assertSame($term, $variables
    ->getTerm());
}