I'm looking for a way to easily create (and teardown) data in a database from data definitions and integrate it in with my PHPUnit tests.
Is there any such thing out there for PHP that has this capability?
Thanks
DBUnit is to JUnit as ??? is to PHPUnit
Moderator: General Moderators
OK, since i'm not getting any replies, i'll describe it more simply.
I want to define what data a particular user would have in the database.
then i would like to have a PHP tool/framework that could parse this file, create the SQL and persist it to the database for me.
Kind of like many of the Java ORM's can do.
I desperatly do not want to make my own. So if anyone out there knows of a opensource free piece of software out there
PLEASE let me know. Thanks.
I want to define what data a particular user would have in the database.
Code: Select all
<user>
<firstName>Bob</firstName>
<lastName>Schmob</lastName>
<birthDate>01/01/2000</birthdate>
<account>
<type>administrator</type>
<createdDate>01/02/2001</createdDate>
</account>
</user>Kind of like many of the Java ORM's can do.
I desperatly do not want to make my own. So if anyone out there knows of a opensource free piece of software out there
PLEASE let me know. Thanks.
Have you heard of simpletest?
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
What kind of testing are you performing? Generally speaking interacting with a database should never happen for Unit Tests. The only time it would be need is if the class being tested is a database abstraction layer (cannot be tested without a database - though even that's not always the case in PHP5) or when mock/stub objects cannot be written (can't think of an example in PHP, Java has far more examples).
It's unlikely you'll find anything concrete. I'd be inclined to contact the PHPUnit community directly and check if they're aware of something like this for PHP. Otherwise you'll have to DIY. Fact is, database libraries in PHP tend to be very easy to write stubs for. I'd say more than a few people have a stub generator sitting around for ADOdb and co.
It's unlikely you'll find anything concrete. I'd be inclined to contact the PHPUnit community directly and check if they're aware of something like this for PHP. Otherwise you'll have to DIY. Fact is, database libraries in PHP tend to be very easy to write stubs for. I'd say more than a few people have a stub generator sitting around for ADOdb and co.
Don't know about a standalone solution, but Symfony framework offsers this kind of functionality, maybe you can use some of it. See Populating a database at http://www.symfony-project.com/book/tru ... ment-Tools.
-
SprudelPaul
- Forum Newbie
- Posts: 1
- Joined: Fri Jun 22, 2007 11:54 am
You're lucky, a couple of days ago PHPDBUnit was released, I think that's what you're looking for:
http://www.ds-o.com/archives/62-PHPDBUn ... PUnit.html
A very early release but better than nothing, I guess.
http://www.ds-o.com/archives/62-PHPDBUn ... PUnit.html
A very early release but better than nothing, I guess.