Slim 4 Testing with PHPUnit

Hi all,

I’m new to the Slim framework and starting to set it up. I see that for Slim3 there was a lot of documentation about Unit testing, but for Slim4 there seems to exist no such docs.

For info, I’m using OpenApiGenerator which already creates empty testclasses that extend PHPUnit\Framework\TestCase. It’s not clear for me though how the Api classes should be instantiated/called (or how you get the ServerRequestInterface and ResponseInterface for example).

Does anyone know about documentation for this that is relevant for Slim 4?


Welcome @sam

The repository slimphp/Slim-Skeleton contains some nice test examples:

Also here are some examples for Slim 4: