We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to unit test controllers which rely on $_POST

Hi all,

I have a controller action that can 2 of 4 things depending on how $_POST is populated. How would I go about building unit tests for that action. I've thought of building a mock object for request and injecting it in the DI, but I was wondering if there is a more generally accepted method.

Split application logic outside controller - keep there only permission checkins / returning response / view etc and do the rest in some service and test this service.