diff --git a/core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php b/core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php
index 5aa980067dacc41499528d81219074a739408f7b..60c4431cf680b2ba29746981bbc652747577cdce 100644
--- a/core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php
+++ b/core/tests/Drupal/Tests/Core/Command/GenerateThemeTest.php
@@ -45,7 +45,7 @@ protected function setUp(): void {
    * @return \Symfony\Component\Process\Process
    *   The PHP process
    */
-  private function generateThemeFromStarterkit() : Process {
+  private function generateThemeFromStarterkit($env = NULL) : Process {
     $install_command = [
       $this->php,
       'core/scripts/drupal',
@@ -54,7 +54,7 @@ private function generateThemeFromStarterkit() : Process {
       '--name="Test custom starterkit theme"',
       '--description="Custom theme generated from a starterkit theme"',
     ];
-    $process = new Process($install_command, NULL);
+    $process = new Process($install_command, NULL, $env);
     $process->setTimeout(60);
     return $process;
   }
@@ -262,20 +262,23 @@ public function testContribStarterkitDevSnapshotWithGitNotInstalled(): void {
 SH;
     file_put_contents($unavailableGitPath . '/git', $bash);
     chmod($unavailableGitPath . '/git', 0755);
-    $oldPath = getenv('PATH');
-    putenv('PATH=' . $unavailableGitPath . ':' . getenv('PATH'));
     // Confirm that 'git' is no longer available.
-    $output = [];
-    exec('git --help', $output, $status);
-    $this->assertEquals(127, $status);
-
-    $process = $this->generateThemeFromStarterkit();
+    $env = [
+      'PATH' => $unavailableGitPath . ':' . getenv('PATH'),
+      'COLUMNS' => 80,
+    ];
+    $process = new Process([
+      'git',
+      '--help',
+    ], NULL, $env);
+    $process->run();
+    $this->assertEquals(127, $process->getExitCode(), 'Fake git used by process.');
+
+    $process = $this->generateThemeFromStarterkit($env);
     $result = $process->run();
     $this->assertEquals("[ERROR] The source theme starterkit_theme has a development version number     \n         (7.x-dev). Determining a specific commit is not possible because git is\n         not installed. Either install git or use a tagged release to generate a\n         theme.", trim($process->getOutput()), $process->getErrorOutput());
     $this->assertSame(1, $result);
     $this->assertFileDoesNotExist($this->getWorkspaceDirectory() . "/themes/test_custom_theme");
-
-    putenv('PATH=' . $oldPath . ':' . getenv('PATH'));
   }
 
   /**