public function ViewEventTest::testQuerySubstitutionsByReference in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/views_event_dispatcher/tests/src/Unit/Views/ViewEventTest.php \Drupal\Tests\views_event_dispatcher\Unit\Views\ViewEventTest::testQuerySubstitutionsByReference()
Query substitutions event by reference test.
Plugin annotation
@SuppressWarnings(PHPMD . UnusedLocalVariable);
File
- modules/
views_event_dispatcher/ tests/ src/ Unit/ Views/ ViewEventTest.php, line 210
Class
- ViewEventTest
- Class ViewEventTest.
Namespace
Drupal\Tests\views_event_dispatcher\Unit\ViewsCode
public function testQuerySubstitutionsByReference() : void {
/** @var \Drupal\views\ViewExecutable $view */
$view = $this
->createMock(ViewExecutable::class);
$expected = [
'test' => 'other',
];
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::VIEWS_QUERY_SUBSTITUTIONS => static function (ViewsQuerySubstitutionsEvent $event) use ($expected) {
$substitutions =& $event
->getSubstitutions();
$substitutions = $expected;
},
]);
$result = views_event_dispatcher_views_query_substitutions($view);
/** @var \Drupal\views_event_dispatcher\Event\Views\ViewsQuerySubstitutionsEvent $event */
$event = $this->manager
->getRegisteredEvent(HookEventDispatcherInterface::VIEWS_QUERY_SUBSTITUTIONS);
self::assertSame($view, $event
->getView());
self::assertSame($expected, $event
->getSubstitutions());
self::assertSame($expected, $result);
}