php - Isolating Zend_Session in PHPUnit tests -


I am testing the authentication functionality of my site as Zend_Auth authorization engine. But the condition of authentication remains between tests and I have to write 'logout' in every tear.

Now everything is fine. But the problem is the following. As for I know Zend_Auth auth uses Zend_Session for data storage. Therefore, the session is normal for all trials. I am confident that this problem can arise in the future.

Can you please tell me what is the best practice session for each exam to be isolated?

Set up and close in the tire down but I have many tests and it can take a lot of time to implement.

PHPUnit allows you (a common set up) for a complete test suite However, this solution Makes a flaw a mask in the design of the test only, because it does not know the reliance on a general global situation. A better solution is to create custom stubs of some sections to control the behavior of selected parts of the system.

In this case you can try to create a stub of Zend_Auth so that it leaves the use of Zend_Session and gives each unit the desired permission for testing.


Comments