orchestral/testbench

Missing dependency "guzzlehttp/promises"

stefanniedermaier opened this issue · 3 comments

  • Testbench Version: ^7.22
  • Laravel Version: -
  • PHP Version: 8.1
  • Database Driver & Version: -

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

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

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