I am working on testing a project, using database input. My application takes as input , individual records ( table rows ) from a mysql table. As I've tested, I have gradually debugged the program so that almost all the records result in correct output, but there are still a few that are causing problems. I would to select ONLY the individual records, that are still causing problems for input, or else suspend the program when one of the records of concern is being taken as input. I'd like to do this if possible without hard coding

Is there a way to set a watch in XDEBUG so that the program is run until a certain record is reached , when it can break, allowing me to step through the code.

Another way I've thought of doing this is somehow to sort the mysql table ( in phpmyadmin? ) so that the problem records would be taken as the first input,

I advise against using data from a database to populate your tests as a change in any of these rows can cause tests to begin failing for no discernible reason. Sure, it might be more work to transform these into datasets for DBUnit or into data providers for PHPUnit, but you will also end up with higher confidence in your tests.

Yes, if you are getting data from a database to test, you should be able to mock that data and run the tests reliably and in any order you want. Celauran's suggestion of datasets or data providers is a good direction.

Your application should instatinate several classes and one of them is the "DB repository" - i.e. a so-so dummy class responsible only for fetching DB data. The business logic is applied to the data received from this class.

For the "DB" class use DBUnit tests (according to our company terminology these are the "Integration tests") to fully test SQL/ORM etc. code that lies outside your business domain boundaries.

And for the business classes - provide a mocked data and test "DBless".

_________________There are 10 types of people in this world, those who understand binary and those who don't

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum