Skip to content

Commit 08bf276

Browse files
authored
fix Process::fake() not matching multi line commands (#50164)
1 parent 51134d6 commit 08bf276

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Illuminate/Process/PendingProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public function withFakeHandlers(array $fakeHandlers)
348348
protected function fakeFor(string $command)
349349
{
350350
return collect($this->fakeHandlers)
351-
->first(fn ($handler, $pattern) => Str::is($pattern, $command));
351+
->first(fn ($handler, $pattern) => $pattern === '*' || Str::is($pattern, $command));
352352
}
353353

354354
/**

tests/Process/ProcessTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,26 @@ public function testBasicProcessFake()
148148
$this->assertTrue($result->successful());
149149
}
150150

151+
public function testBasicProcessFakeWithMultiLineCommand()
152+
{
153+
$factory = new Factory;
154+
155+
$factory->preventStrayProcesses();
156+
157+
$factory->fake([
158+
'*' => 'The output',
159+
]);
160+
161+
$result = $factory->run(<<<'COMMAND'
162+
git clone --depth 1 \
163+
--single-branch \
164+
--branch main \
165+
git://some-url .
166+
COMMAND);
167+
168+
$this->assertSame(0, $result->exitCode());
169+
}
170+
151171
public function testProcessFakeExitCodes()
152172
{
153173
$factory = new Factory;

0 commit comments

Comments
 (0)