public function EntityEventVariablesTest::testCommentEvent in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\EntityEventVariablesTest::testCommentEvent()
Test a CommentPreprocessEvent.
File
- modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ EntityEventVariablesTest.php, line 57
Class
- EntityEventVariablesTest
- Class EntityEventVariablesTest.
Namespace
Drupal\Tests\preprocess_event_dispatcher\UnitCode
public function testCommentEvent() : void {
$comment = EntityMockFactory::getMock(CommentInterface::class, 'comment', 'comment_bundle', 'comment_view_mode');
$commentedEntity = Mockery::mock(ContentEntityInterface::class);
$variablesArray = $this
->createVariablesArray();
$variablesArray['comment'] = $comment;
$variablesArray['commented_entity'] = $commentedEntity;
$variablesArray['view_mode'] = $comment
->getViewMode();
/** @var \Drupal\preprocess_event_dispatcher\Variables\CommentEventVariables $variables */
$variables = $this
->getVariablesFromCreatedEvent(CommentPreprocessEvent::class, $variablesArray);
self::assertInstanceOf(CommentEventVariables::class, $variables);
$this
->assertAbstractEntityEventVariables($variables, $comment);
self::assertSame($comment, $variables
->getComment());
self::assertSame($commentedEntity, $variables
->getCommentedEntity());
}