diff --git a/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php b/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php
index 9b249b2fc0..73a6d31e8b 100644
--- a/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php
+++ b/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php
@@ -3,6 +3,7 @@
 namespace Drupal\Core\Test;
 
 use Drupal\Core\Database\Database;
+use Drupal\Tests\Listeners\SimpletestUiPrinter;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\Process\PhpExecutableFinder;
 
@@ -102,17 +103,16 @@ public function phpUnitCommand() {
     $reflector = new \ReflectionClass($autoloader);
     $vendor_dir = dirname(dirname($reflector->getFileName()));
 
-    // Don't use the committed version in composer's bin dir if running on
-    // windows.
+    // The file in Composer's bin dir is a *nix link, which does not work when
+    // extracted from a tarball and generally not on Windows.
+    $command = $vendor_dir . '/phpunit/phpunit/phpunit';
     if (substr(PHP_OS, 0, 3) == 'WIN') {
+      // On Windows it is necessary to run the script using the PHP executable.
       $php_executable_finder = new PhpExecutableFinder();
       $php = $php_executable_finder->find();
-      $phpunit_bin = escapeshellarg($php) . ' -f ' . escapeshellarg($vendor_dir . '/phpunit/phpunit/composer/bin/phpunit') . ' --';
+      $command = $php . ' -f ' . escapeshellarg($command) . ' --';
     }
-    else {
-      $phpunit_bin = $vendor_dir . '/phpunit/phpunit/phpunit';
-    }
-    return $phpunit_bin;
+    return $command;
   }
 
   /**
@@ -154,7 +154,7 @@ public function runCommand(array $unescaped_test_classnames, $phpunit_file, &$st
       '--log-junit',
       escapeshellarg($phpunit_file),
       '--printer',
-      '\\\Drupal\\\Tests\\\Listeners\\\SimpletestUiPrinter',
+      escapeshellarg(SimpletestUiPrinter::class),
     );
 
     // Optimized for running a single test.
@@ -215,6 +215,7 @@ public function runTests($test_id, array $unescaped_test_classnames, &$status =
     $output = [];
     $this->runCommand($unescaped_test_classnames, $phpunit_file, $status, $output);
 
+    $rows = [];
     if ($status == TestStatus::PASS) {
       $rows = JUnitConverter::xmlToRows($test_id, $phpunit_file);
     }
