You are here

public function EntityEventVariablesTest::testParagraphEvent in Hook Event Dispatcher 8

Test a ParagraphPreprocessEvent.

File

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

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

public function testParagraphEvent() {
  $paragraph = new EntityMock('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\hook_event_dispatcher\Event\Preprocess\Variables\ParagraphEventVariables $variables */
  $variables = $this
    ->getVariablesFromCreatedEvent(ParagraphPreprocessEvent::class, $variablesArray);
  $this
    ->assertInstanceOf(ParagraphEventVariables::class, $variables);
  $this
    ->assertAbstractEntityEventVariables($variables, $paragraph);
  $this
    ->assertSame($paragraph, $variables
    ->getParagraph());
}