From 449b333d5bf2e1a9f31414ce73b68b51ed8e15fd Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Thu, 12 Mar 2020 14:39:41 +0000
Subject: [PATCH] Issue #3114041 by swatichouhan012, longwave, chr.fritsch,
 alexpott, mondrake: PhpUnit 8 tests breaking because of compatibility issue
 with setUp()

---
 .../PhpUnitCompatibility/PhpUnit8/ClassWriter.php          | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php
index 77ccb953390b..8e2f5ef20d69 100644
--- a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php
+++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php
@@ -43,9 +43,14 @@ public static function mutateTestBase($autoloader) {
     $alteredCode = file_get_contents($alteredFile = $vendor_dir . '/phpunit/phpunit/src/Framework/TestCase.php');
     $alteredCode = preg_replace('/^    ((?:protected|public)(?: static)? function \w+\(\)): void/m', '    $1', $alteredCode);
     $alteredCode = str_replace("__DIR__ . '/../Util/", "'$vendor_dir/phpunit/phpunit/src/Util/", $alteredCode);
-    $filename = __DIR__ . '/../../../../../../sites/simpletest/TestCase.php';
+    $simpletest_directory = __DIR__ . '/../../../../../../sites/simpletest';
     // Only write when necessary.
+    $filename = $simpletest_directory . '/TestCase.php';
     if (!file_exists($filename) || md5_file($filename) !== md5($alteredCode)) {
+      // Create directory when necessary.
+      if (!file_exists($simpletest_directory)) {
+        mkdir($simpletest_directory, 0777, TRUE);
+      }
       file_put_contents($filename, $alteredCode);
     }
     include $filename;
-- 
GitLab