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

TestCase example is confusing. Why parameters in the setUp() method?

I'm reading the documentation about unit testing and in the example there is a class caleed UnitTestCase. In that class the setUp method signature is as follows:

public function setUp(Phalcon\DiInterface $di = NULL, Phalcon\Config $config = NULL)

My question is: since PHPUnit will instantiate that class automatically, why is the setUp method expecting arguments? How and when would someone pass arguments to that method? I'm scratching my head around it.

Thanks!



32.2k
Accepted
answer

The penny finally dropped! I finally realized that the setUp() method is to be called by a child class using parent::setUp($di, $config). So obvious!