Skip to content
Snippets Groups Projects
Unverified Commit 15b39f02 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3143604 by chr.fritsch, Taran2L, longwave, alexpott, dungahk:...

Issue #3143604 by chr.fritsch, Taran2L, longwave, alexpott, dungahk: PhpUnitCompatibility\PhpUnit8\ClassWriter cannot detect PHPUnit source directory  when running PHPStan check
parent beee0426
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
...@@ -23,7 +23,7 @@ private function __construct() { ...@@ -23,7 +23,7 @@ private function __construct() {
/** /**
* Mutates the TestCase class from PHPUnit to make it compatible with Drupal. * Mutates the TestCase class from PHPUnit to make it compatible with Drupal.
* *
* @param object $autoloader * @param \Composer\Autoload\ClassLoader $autoloader
* The autoloader. * The autoloader.
* *
* @throws \ReflectionException * @throws \ReflectionException
...@@ -37,12 +37,12 @@ public static function mutateTestBase($autoloader) { ...@@ -37,12 +37,12 @@ public static function mutateTestBase($autoloader) {
return; return;
} }
// Inspired by Symfony's simple-phpunit remove typehints from TestCase. // Inspired by Symfony's simple-phpunit remove typehints from TestCase.
$reflector = new \ReflectionClass($autoloader); $alteredFile = $autoloader->findFile('PHPUnit\Framework\TestCase');
$vendor_dir = dirname($reflector->getFileName(), 2); $phpunit_dir = dirname($alteredFile, 3);
// Mutate TestCase code to make it compatible with Drupal 8 and 9 tests. // Mutate TestCase code to make it compatible with Drupal 8 and 9 tests.
$alteredCode = file_get_contents($alteredFile = $vendor_dir . '/phpunit/phpunit/src/Framework/TestCase.php'); $alteredCode = file_get_contents($alteredFile);
$alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode); $alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode);
$alteredCode = str_replace("__DIR__ . '/../Util/", "'$vendor_dir/phpunit/phpunit/src/Util/", $alteredCode); $alteredCode = str_replace("__DIR__ . '/../Util/", "'$phpunit_dir/src/Util/", $alteredCode);
$simpletest_directory = __DIR__ . '/../../../../../../sites/simpletest'; $simpletest_directory = __DIR__ . '/../../../../../../sites/simpletest';
// Only write when necessary. // Only write when necessary.
$filename = $simpletest_directory . '/TestCase.php'; $filename = $simpletest_directory . '/TestCase.php';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment