diff --git a/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php b/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php
index e8adb63c5b749e156f8012e6dd202c161aebff5a..908535c1c7c800cf3f62ce4b22d5241baca14425 100644
--- a/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php
+++ b/core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php
@@ -44,8 +44,8 @@ public function generateWarnings($collect_errors = FALSE) {
     // Tell Drupal error reporter to send errors to Simpletest or not.
     define('SIMPLETEST_COLLECT_ERRORS', $collect_errors);
     // This will generate a notice.
-    $bananas = [];
-    $monkey_love = $bananas[1];
+    $notice = new \stdClass();
+    $notice == 1 ? 1 : 0;
     // This will generate a warning.
     $obj = new \stdClass();
     $obj->p =& $obj;
diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
index 74ec38cd62a8300c6c9e204d509957d43a1c5cba..ac76bfe538604259019584556991bb6bfc92329a 100644
--- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
+++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
@@ -31,7 +31,7 @@ public function testErrorHandler() {
     $config = $this->config('system.logging');
     $error_notice = [
       '%type' => 'Notice',
-      '@message' => 'Undefined offset: 1',
+      '@message' => 'Object of class stdClass could not be converted to int',
       '%function' => 'Drupal\error_test\Controller\ErrorTestController->generateWarnings()',
       '%file' => drupal_get_path('module', 'error_test') . '/error_test.module',
     ];