Skip to content

Commit 0def355

Browse files
committed
refactor(tests): Refactor find method in ExecutableFinder
- Remove unnecessary implementation of `find` method in mock `ExecutableFinder`
1 parent 8d17c4f commit 0def355

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/Feature/ConfigCommandTest.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,10 @@
115115

116116
it('will throw another `Command not found` ProcessFailedException for edit config', function (): void {
117117
app()->singleton(ExecutableFinder::class, static function () {
118-
return new class() extends ExecutableFinder {
119-
public function find(string $name, ?string $default = null, array $extraDirs = []): string
120-
{
121-
return 'foo';
122-
}
123-
};
118+
$mockExecutableFinder = \Mockery::mock(ExecutableFinder::class);
119+
$mockExecutableFinder->allows('find')->andReturn('foo');
120+
121+
return $mockExecutableFinder;
124122
});
125123

126124
$this->artisan(ConfigCommand::class, [
@@ -132,11 +130,10 @@ public function find(string $name, ?string $default = null, array $extraDirs = [
132130

133131
it('will throw RuntimeException for edit config', function (): void {
134132
app()->singleton(ExecutableFinder::class, static function () {
135-
return new class() extends ExecutableFinder {
136-
public function find(string $name, ?string $default = null, array $extraDirs = []): void
137-
{
138-
}
139-
};
133+
$mockExecutableFinder = \Mockery::mock(ExecutableFinder::class);
134+
$mockExecutableFinder->allows('find')->andReturnNull();
135+
136+
return $mockExecutableFinder;
140137
});
141138

142139
$this->artisan(ConfigCommand::class, [

0 commit comments

Comments
 (0)