Question

I am working on a PHP (Zend Framework 1.12.1) application that ties into a database in a somewhat unique way.

Basically, we have an Oracle database that is a "black box" to me. I do not have privileges to select, update, insert, or delete any rows or tables directly. I have only been given access to database views (select only), and when I want to insert/update/delete data, I have to call one or more stored procedures. I have no idea what the actual table structures are, and I don't think anyone is going to give me access at any point.

All of this makes unit testing my models very difficult (not to mention writing them), as ZF seems to assume that your application has full privileges in the database. (This is why I have only done manual testing on my models so far, and my models are somewhat unusual.)

My application works, but I'm tired of manual testing.

Has anybody else been in this situation before? Can you recommend concrete steps to implement automated PHPUnit tests in an environment with limited database privileges? I have already asked the db admin to give me a stored procedure called resetTestData(), which would allow me to run my tests beginning from a consistent state each time, but I am afraid ZF won't let me test using that stored procedure for set up and/or tear down. Apparently, Zend_Test_PHPUnit_DatabaseTestCase attempts to truncate the dataset before each test and then calls getDataSet() to get the data and re-populate the database. Work around?

No correct solution

OTHER TIPS

3 different types of testing: - unit testing (low level using mocks etc) - integration testing (low level using real datasource) - end to end testing (through the browser)

Either use mocks where you dont need the database or do end-to-end tests with selenium which will drive the browser as a user

Create an testable application is not such easy.

You have different types of tests, if you are using unit test, you never should call the db, webservices, even file system resources. All these stuff must be mocked. I know is hard, but if you can't you have code smell.

But, if you still need to access to the db, you can create your own testing environment, when you put a local Oracle Database and you can handle the permission as you want.

You can create a APPLICATION_ENV for your system as you can read a particular config when you run tests, just for use the Local connection and not the QA (For example) connection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top