Skip to content

Commit 3ee4b63

Browse files
committed
Re-enable response macro in unit tests
1 parent 71a4679 commit 3ee4b63

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/ServiceProvider.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function boot()
2929

3030
$this->app->booted(function (): void {
3131
// register response macro "image"
32-
if (!$this->app->runningInConsole() && !ResponseFacade::hasMacro(Facades\Image::BINDING)) {
32+
if ($this->shouldCreateResponseMacro()) {
3333
ResponseFacade::macro(Facades\Image::BINDING, function (
3434
Image $image,
3535
null|string|Format|MediaType|FileExtension $format = null,
@@ -63,4 +63,16 @@ public function register()
6363
);
6464
});
6565
}
66+
67+
/**
68+
* Determine if response macro should be created
69+
*/
70+
private function shouldCreateResponseMacro(): bool
71+
{
72+
if (!$this->app->runningUnitTests() && $this->app->runningInConsole()) {
73+
return false;
74+
}
75+
76+
return !ResponseFacade::hasMacro(Facades\Image::BINDING);
77+
}
6678
}

0 commit comments

Comments
 (0)