diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index f13c0e7..0d4d931 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -799,7 +800,7 @@ public function setDisplay($display_id = NULL) { // Ensure the requested display exists. if (!$this->displayHandlers->has($display_id)) { - debug(format_string('setDisplay() called with invalid display ID "@display".', ['@display' => $display_id])); + trigger_error(new FormattableMarkup('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 6ef104c..8199073 100644 --- a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php +++ b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php @@ -196,8 +196,12 @@ public function testSetDisplayWithInvalidDisplay() { $view->initDisplay(); // Error is triggered while calling the wrong display. - $this->setExpectedException(\PHPUnit_Framework_Error::class); - $view->setDisplay('invalid'); + try { + $view->setDisplay('invalid'); + } + catch (\PHPUnit_Framework_Error $e) { + $this->assertEquals('setDisplay() called with invalid display ID "invalid".', $e->getMessage()); + } $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')));