-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Guzzle test server | ||
|
||
This server has long been part of the Guzzle Http client. Since late 2021 it | ||
was extracted to its own package. | ||
|
||
The server is useful to use in your integration tests. | ||
|
||
```php | ||
|
||
use GuzzleHttp\Server\Server; | ||
|
||
Server::start(); | ||
register_shutdown_function(static function () { | ||
Server::stop(); | ||
}); | ||
|
||
Server::enqueue([ | ||
new Response(201), | ||
]); | ||
|
||
$myHttpClient = MyClient(); | ||
$response = $this->makeRequest('GET', Sever::$url); | ||
// $response will be 201 | ||
|
||
$requests = Server::received(); | ||
// $request[0] is the one sent by MyClient | ||
|
||
``` |