diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 551c1024e0bef..5efa5249bc53e 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -91,7 +91,9 @@ public function restoreService(string $name): bool { return $oldService; }); } else { - unset($container[$oldService]); + // The service was not registered before the test override. + // Remove the test registration so the container returns to its prior state. + unset($container[$name]); }