protected function AreaDisplayLinkTest::assertWarningMessages in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php \Drupal\Tests\views\Kernel\Handler\AreaDisplayLinkTest::assertWarningMessages()
- 10 core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php \Drupal\Tests\views\Kernel\Handler\AreaDisplayLinkTest::assertWarningMessages()
Assert the warning messages are shown after changing the page_1 display.
Parameters
\Drupal\views\ViewExecutable $view: The view to check.
array $unequal_options: An array of options that should be unequal.
Throws
\Exception
1 call to AreaDisplayLinkTest::assertWarningMessages()
- AreaDisplayLinkTest::testAreaDisplayLink in core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaDisplayLinkTest.php - Tests the views area display_link handler.
File
- core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaDisplayLinkTest.php, line 389
Class
- AreaDisplayLinkTest
- Tests the core views_handler_area_display_link handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
protected function assertWarningMessages(ViewExecutable $view, array $unequal_options) {
$messenger = $this->container
->get('messenger');
// Create a list of options to check.
// @see \Drupal\views\Plugin\views\area\DisplayLink::validate()
$options = [
'filters' => 'Filter criteria',
'sorts' => 'Sort criteria',
'pager' => 'Pager',
'arguments' => 'Contextual filters',
];
// Create a list of options to check.
// @see \Drupal\views\Plugin\views\area\DisplayLink::validate()
$unequal_options_text = implode(', ', array_intersect_key($options, array_flip($unequal_options)));
$errors = $view
->validate();
$messages = $messenger
->messagesByType(MessengerInterface::TYPE_WARNING);
$this
->assertCount(0, $errors);
$this
->assertCount(3, $messages);
$this
->assertSame('<em class="placeholder">Block 1</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Block 1</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[0]
->__toString());
$this
->assertSame('<em class="placeholder">Page 1</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 2</em> display which uses different settings than the <em class="placeholder">Page 1</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[1]
->__toString());
$this
->assertSame('<em class="placeholder">Page 2</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Page 2</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[2]
->__toString());
$messenger
->deleteAll();
// If the master display is shown in the UI, warnings should be shown for
// this display as well.
$this
->config('views.settings')
->set('ui.show.master_display', TRUE)
->save();
$errors = $view
->validate();
$messages = $messenger
->messagesByType(MessengerInterface::TYPE_WARNING);
$this
->assertCount(0, $errors);
$this
->assertCount(4, $messages);
$this
->assertSame('<em class="placeholder">Master</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Master</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[0]
->__toString());
$this
->assertSame('<em class="placeholder">Block 1</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Block 1</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[1]
->__toString());
$this
->assertSame('<em class="placeholder">Page 1</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 2</em> display which uses different settings than the <em class="placeholder">Page 1</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[2]
->__toString());
$this
->assertSame('<em class="placeholder">Page 2</em>: The link in the <em class="placeholder">header</em> area points to the <em class="placeholder">Page 1</em> display which uses different settings than the <em class="placeholder">Page 2</em> display for: <em class="placeholder">' . $unequal_options_text . '</em>. To make sure users see the exact same result when clicking the link, please check that the settings are the same.', $messages[3]
->__toString());
$messenger
->deleteAll();
$this
->config('views.settings')
->set('ui.show.master_display', FALSE)
->save();
}