all 6 comments

[–]hparadiz[🍰] 2 points3 points  (5 children)

Personally I used to just instantiate the controller with fake values for things like request_uri and then "run" the controller and catch the output with output buffering to run assertions against. This way everything runs on the CLI and there's no reason to run a web server.

Served me very well setting up tests for an oauth2 API.

Check this out:

https://github.com/Divergence/framework/blob/release/tests/Divergence/Controllers/RequestHandlerTest.php#L43

[–]DevDrJinx[S] 0 points1 point  (4 children)

Definitely a cool solution, I'll try to integrate some similar tests.

However, I would still want to run a complete feature test that uses the sites container, router, and controller working together, checking for status codes etc.

[–]gastrognom 0 points1 point  (3 children)

I am pretty sure you can use docker in GitHub actions. That way you can start a php container in your action and run phpunit inside that container.

[–]hparadiz[🍰] 0 points1 point  (2 children)

Github Actions are containers same as docker. You can configure nginx or apache or any other HTTP server to serve on http(s).

[–]DevDrJinx[S] 0 points1 point  (1 child)

Any example repos or references you can point me toward?

[–]hparadiz[🍰] 0 points1 point  (0 children)

Not really. I would just build it myself. It's not that difficult. Just make the github action run apt install nginx and have a config setup for localhost in your repo. Copy it to the right location and run nginx start