diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/ClassWriter.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/ClassWriter.php
index 0362882d1a66414921efd0248fc4a01d998f6681..5870de06ab8d76efe8377223a5af3675fdf6273c 100644
--- a/core/tests/Drupal/TestTools/PhpUnitCompatibility/ClassWriter.php
+++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/ClassWriter.php
@@ -98,7 +98,7 @@ private static function alterTestCase(ClassLoader $autoloader): void {
    *   The full path of the file to be included.
    */
   private static function flushAlteredCodeToFile(string $file_name, string $altered_code): string {
-    $directory = __DIR__ . '/../../../../../../sites/simpletest';
+    $directory = __DIR__ . '/../../../../../sites/simpletest';
     $full_path = $directory . '/' . $file_name;
 
     // Only write when necessary.