Skip to content

Commit 2228474

Browse files
authored
Fix inconsistent escaping of artisan argument (#39953)
* Fix inconsistent escaping of artisan argument * Update tests * Fix test
1 parent ec0d23b commit 2228474

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/Illuminate/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function phpBinary()
116116
*/
117117
public static function artisanBinary()
118118
{
119-
return defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
119+
return ProcessUtils::escapeArgument(defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan');
120120
}
121121

122122
/**

tests/Console/ConsoleEventSchedulerTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ public function testCommandCreatesNewArtisanCommand()
101101

102102
$events = $schedule->events();
103103
$binary = $escape.PHP_BINARY.$escape;
104-
$this->assertEquals($binary.' artisan queue:listen', $events[0]->command);
105-
$this->assertEquals($binary.' artisan queue:listen --tries=3', $events[1]->command);
106-
$this->assertEquals($binary.' artisan queue:listen --tries=3', $events[2]->command);
104+
$artisan = $escape.'artisan'.$escape;
105+
$this->assertEquals($binary.' '.$artisan.' queue:listen', $events[0]->command);
106+
$this->assertEquals($binary.' '.$artisan.' queue:listen --tries=3', $events[1]->command);
107+
$this->assertEquals($binary.' '.$artisan.' queue:listen --tries=3', $events[2]->command);
107108
}
108109

109110
public function testCreateNewArtisanCommandUsingCommandClass()
@@ -115,7 +116,8 @@ public function testCreateNewArtisanCommandUsingCommandClass()
115116

116117
$events = $schedule->events();
117118
$binary = $escape.PHP_BINARY.$escape;
118-
$this->assertEquals($binary.' artisan foo:bar --force', $events[0]->command);
119+
$artisan = $escape.'artisan'.$escape;
120+
$this->assertEquals($binary.' '.$artisan.' foo:bar --force', $events[0]->command);
119121
}
120122

121123
public function testCallCreatesNewJobWithTimezone()

tests/Console/Scheduling/EventTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testBuildCommandInBackgroundUsingUnix()
4747

4848
$scheduleId = '"framework'.DIRECTORY_SEPARATOR.'schedule-eeb46c93d45e928d62aaf684d727e213b7094822"';
4949

50-
$this->assertSame("(php -i > '/dev/null' 2>&1 ; '".PHP_BINARY."' artisan schedule:finish {$scheduleId} \"$?\") > '/dev/null' 2>&1 &", $event->buildCommand());
50+
$this->assertSame("(php -i > '/dev/null' 2>&1 ; '".PHP_BINARY."' 'artisan' schedule:finish {$scheduleId} \"$?\") > '/dev/null' 2>&1 &", $event->buildCommand());
5151
}
5252

5353
public function testBuildCommandInBackgroundUsingWindows()
@@ -61,7 +61,7 @@ public function testBuildCommandInBackgroundUsingWindows()
6161

6262
$scheduleId = '"framework'.DIRECTORY_SEPARATOR.'schedule-eeb46c93d45e928d62aaf684d727e213b7094822"';
6363

64-
$this->assertSame('start /b cmd /c "(php -i & "'.PHP_BINARY.'" artisan schedule:finish '.$scheduleId.' "%errorlevel%") > "NUL" 2>&1"', $event->buildCommand());
64+
$this->assertSame('start /b cmd /c "(php -i & "'.PHP_BINARY.'" "artisan" schedule:finish '.$scheduleId.' "%errorlevel%") > "NUL" 2>&1"', $event->buildCommand());
6565
}
6666

6767
public function testBuildCommandSendOutputTo()

0 commit comments

Comments
 (0)