empress-php / empress

Empress is a flexible microframework for creating async web applications in PHP 8.1.
MIT License
15 stars 0 forks source link

Functional testing #32

Closed jakobmats closed 3 years ago

jakobmats commented 3 years ago

I'm thinking about writing a PHPUnit extension (as a separate package) that would make it easy to conduct functional testing. The client would not need to spawn a server but instead rely only on an object that implements RequestHandler. The client, based on a given set of handler capabilities, could make requests and set expectations on the responses.


// ...
$router = $app->getRouter(); // Router implements RequestHandler
$client = new Client($router, new EmpressRouterCapabilities());

$response = yield $this->client->post('/form', form: ['name' => 'Alex']);

$response
   ->will(static::haveStatus(200), static::containBody('Hello, Alex'));
jakobmats commented 3 years ago

While it seems like a good idea it's much harder to implement that just going with amphp/http-client. Closing this for now.