PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jun 17, 2018 10:35 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Apr 02, 2012 12:24 pm 
Offline
Forum Commoner

Joined: Mon Sep 27, 2010 3:26 pm
Posts: 73
Hi,

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,

Are either of these possible, or is there a better way?

Thanks in advance,

KC


Top
 Profile  
 
PostPosted: Sat Jan 20, 2018 7:34 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Sat Jan 20, 2018 4:23 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13560
Location: New York, NY, US
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.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Mon Jan 22, 2018 12:29 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
+1 for both oppionions above

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


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

Jump to:  
Powered by phpBB® Forum Software © phpBB Group