I am testing a Zend application using PHPUnit. From time to time, I want to access a DB table before and after a test to see that a test has worked correctly. For example, when the test adds a record, I want to check the value of the primary key beforehand and afterwards.
In these cases, what’s the best way to get access the DB connection that Zend is using? I realise that I could set up a separate connection for PHPUnit, but would like to avoid this if possible. (It saves me having to setup shared configuration files).
My Zend DB config parameters are in the application.ini, and the db is bootstrapped in Bootstrap.php, with the line $this->bootstrap(‘db’).
Thanks!
So, this seems to work:
Let me know if you have a better method!