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

Unit testing mocking Models and/or ResultSet's

Is there a way to mock or a complete Unit Test example for an application using Phalcon PHP?

I'm developing a RestfulAPI but I'm above many problems to mock and organizing test. There isn't a visible and complete example in documentation. For example, I have a resource called "areas", by the request "GET /areas", at Controller I call Areas::find(). How to mock it? How to mock multiple models used inside the same Controller? My application has many validation and business logic and is necessary apply unit testing.

Thanks



32.2k
edited Oct '15

Maybe this will help: https://sebastian-bergmann.de/archives/883-Stubbing-and-Mocking-Static-Methods.html

EDIT: it seems it's deprecated now!