You are here

public function EntityEventVariablesTest::testTaxonomyTermEvent in Hook Event Dispatcher 8

Test a TaxonomyTermPreprocessEvent.

File

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

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

public function testTaxonomyTermEvent() {
  $term = new EntityMock('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\hook_event_dispatcher\Event\Preprocess\Variables\TaxonomyTermEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(TaxonomyTermPreprocessEvent::class, $variablesArray);
  $this
    ->assertInstanceOf(TaxonomyTermEventVariables::class, $variables);
  $this
    ->assertAbstractEntityEventVariables($variables, $term);
  $this
    ->assertSame($term, $variables
    ->getTerm());
}