Skip to content

Commit

Permalink
fix Process::fake() not matching multi line commands (#50164)
Browse files Browse the repository at this point in the history
  • Loading branch information
SjorsO authored Feb 20, 2024
1 parent 51134d6 commit 08bf276
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Process/PendingProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function withFakeHandlers(array $fakeHandlers)
protected function fakeFor(string $command)
{
return collect($this->fakeHandlers)
->first(fn ($handler, $pattern) => Str::is($pattern, $command));
->first(fn ($handler, $pattern) => $pattern === '*' || Str::is($pattern, $command));
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/Process/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ public function testBasicProcessFake()
$this->assertTrue($result->successful());
}

public function testBasicProcessFakeWithMultiLineCommand()
{
$factory = new Factory;

$factory->preventStrayProcesses();

$factory->fake([
'*' => 'The output',
]);

$result = $factory->run(<<<'COMMAND'
git clone --depth 1 \
--single-branch \
--branch main \
git://some-url .
COMMAND);

$this->assertSame(0, $result->exitCode());
}

public function testProcessFakeExitCodes()
{
$factory = new Factory;
Expand Down

0 comments on commit 08bf276

Please sign in to comment.