DBUnit is to JUnit as ??? is to PHPUnit

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
loesak
Forum Newbie
Posts: 2
Joined: Tue Jun 12, 2007 3:03 pm

DBUnit is to JUnit as ??? is to PHPUnit

Post by loesak »

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
loesak
Forum Newbie
Posts: 2
Joined: Tue Jun 12, 2007 3:03 pm

Post by loesak »

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.

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>
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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Have you heard of simpletest?
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

loesak wrote: 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 bet MDB2 could do that for you, as well as Propel.
User avatar
dbevfat
Forum Contributor
Posts: 126
Joined: Tue Jun 28, 2005 2:47 pm
Location: Ljubljana, Slovenia

Post by dbevfat »

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

Post by SprudelPaul »

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. :wink:
ds
Forum Newbie
Posts: 1
Joined: Sun Jun 24, 2007 10:59 pm

Post by ds »

I wouldn't necessarily call it released. I hope to have the first beta out in next month. If there is anybody that would like to do some early testing and offer their feedback I would enjoy the help.
Post Reply