I have a ini file with db connection settings. I am creating an installer and need help to:
- test db connection settings in ini file with errors (wrong user/pass or cannot select db)
- insert db structure using .sql file.
Is this possible with ZF, I can’t find any info anywhere. Should I just do this using direct queries?
Thanks!
In your unit test, you could probably call
$adapter->getConnect()within atry/catchthat checks for aZend_Db_Adapter_Exception, subclasses of which are thrown on a failed connection. In thecatch, you can call$this->fail()to signal the failed test.But typically, you would have a different set of db connection params when
APPLICATION_ENV = 'testing'than you would for the otherAPPLICATION_ENV‘s. So in this sense, I am with @jakenoble. It sounds less like a unit testing issue than a deployment issue. As such, some kind of command-line script – even one that uses the same bootstrap as the main app – might be more appropriate.