orchestral / testbench

Laravel Testing Helper for Packages Development
https://packages.tools/testbench
MIT License
2.1k stars 136 forks source link

Missing dependency "guzzlehttp/promises" #353

Closed stefanniedermaier closed 1 year ago

stefanniedermaier commented 1 year ago

Description:

When creating a Laravel package and installing "orchestra/testbench": "^7.22" only (as a dev dependency), "guzzlehttp/promises" is not installed as a dependency.
Therefore creating a test, which mocks a http request fails.

Steps To Reproduce:

Create a simple Unit-Test containing a mocked request;

# Mock
Http::fake([
   config('base_url') . '*' => Http::response($response, $statusCode, $headers),
]);

and running the PHPUnit-Test, results in

# Error
Error: Call to undefined function GuzzleHttp\Promise\promise_for()

/src/vendor/laravel/framework/src/Illuminate/Http/Client/Factory.php:98
/src/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338
crynobone commented 1 year ago

https://packages.tools/testbench/troubleshooting.html#class-guzzlehttp-client-not-found

stefanniedermaier commented 1 year ago

Thanks for the hint, but i can see two issues here:

  1. adding optional dependencies to the installation instruction could help developers not running into this issue
  2. adding optional dependencies to composer.json suggests would make it more transparent when installing the package
crynobone commented 1 year ago

No plan to change this, also this requirement is already suggested by Laravel Framework (and we don't want to include another line where it can become outdated to Laravel Framework suggestion): https://github.com/laravel/framework/blob/9.x/composer.json#L165