diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index a4d653ab819..f13c0e752db 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -2,7 +2,6 @@ namespace Drupal\views; -use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Tags; use Drupal\Core\Routing\RouteProviderInterface; @@ -800,7 +799,7 @@ class ViewExecutable { // Ensure the requested display exists. if (!$this->displayHandlers->has($display_id)) { - trigger_error(new FormattableMarkup('setDisplay() called with invalid display ID "@display".', ['@display' => $display_id])); + debug(format_string('setDisplay() called with invalid display ID "@display".', ['@display' => $display_id])); return FALSE; } diff --git a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php index 4c1f3a1f484..a568363bb90 100644 --- a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php +++ b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php @@ -196,12 +196,8 @@ class ViewExecutableTest extends ViewsKernelTestBase { $view->initDisplay(); // Error is triggered while calling the wrong display. - try { - $view->setDisplay('invalid'); - } - catch (\PHPUnit_Framework_Error $e) { - $this->assertEquals('setDisplay() called with invalid display ID "invalid".', $e->getMessage()); - } + $this->setExpectedException(\PHPUnit_Framework_Error::class); + $view->setDisplay('invalid'); $this->assertEqual($view->current_display, 'default', 'If setDisplay is called with an invalid display id the default display should be used.'); $this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers->get('default')));