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 setup PHPUnit test with multi module setup

I have created a test application with single setup and used PHPUnit as per tutorial https://docs.phalcon.io/en/latest/reference/unit-testing.html and it works well.

Can anybody help me how do I setup it for multi module setup?



7.9k

Hi,

If you want to do unit test make sure your code is SOLID compliant. And it would me useful if you show us part of code that you want to test

I am ok to write the unit tests, my question was how do i setup phalcon to work with phpunit while using multimodule setup. See the link https://docs.phalcon.io/en/latest/reference/unit-testing.html, the steps are given for single module setup.



7.9k
Accepted
answer

It unit test it doesnt care wheter you apps is single or multimodule. Given example just give you DI and config in test suite. For example if you want to test AddUser function in UserModule, you have to create User object and mock its dependency. then call it in unit test

$user = new \App\Module\User\User.php;
$this->assertTrue($user->addUser());

Thank you Prasetyo.