You are here

public function EntityEventVariablesTest::testParagraphEvent in Hook Event Dispatcher 8.2

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

Test a ParagraphPreprocessEvent.

File

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

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

public function testParagraphEvent() : void {
  $paragraph = EntityMockFactory::getMock(ParagraphInterface::class, 'paragraph', 'paragraph_bundle', 'paragraph_view_mode');
  $variablesArray = $this
    ->createVariablesArray();
  $variablesArray['paragraph'] = $paragraph;
  $variablesArray['theme_hook_original'] = $paragraph
    ->getEntityType();
  $variablesArray['view_mode'] = $paragraph
    ->getViewMode();

  /** @var \Drupal\preprocess_event_dispatcher\Variables\ParagraphEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(ParagraphPreprocessEvent::class, $variablesArray);
  self::assertInstanceOf(ParagraphEventVariables::class, $variables);
  $this
    ->assertAbstractEntityEventVariables($variables, $paragraph);
  self::assertSame($paragraph, $variables
    ->getParagraph());
}