Let me start by saying I'm new to writing tests so I may have my tools and/or testing concepts mixed up.
I've build out an api using Laravel 5.2. I've written tests in ./tests extending TestCase to cover nearly all elements of the api requests and responses.
Moving on to some of the functionality of the api I needed to make GET requests using query parameters. I found this wasn't easy or possible to do using Laravel's $this->call('GET',$url) method so I added Guzzle to accomplish this.
Great....everything works when I run one set of tests at a time.
But, when I run the entire test sequence for the api I get a TOO MANY CONNECTIONS error stemming from the number of HTTP requests triggered by the tests using Guzzle. To address this I tried to use Guzzle's Async Requests feature.
The issue now is that the PHPUnit is completing all the tests but the $promise()->then() is never executed.
Any suggestions?
public function testGet()
{
$promise = $this->client->requestAsync('GET','clients');
$promise->then(
function (ResponseInterface $response) {
$data = json_decode($response->getBody());
// this never get called
print_r($data);
}
);
$promise->wait();
}