PHPUnit & DatabaseTestCase

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
User avatar
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

PHPUnit & DatabaseTestCase

Post by VladSun »

Hi all :)

I am having big troubles with running PHPUnit Database test cases.
If I set runTestInSeparateProcess to false and I run a single test case everything is OK. But if I run all tests then some of the tests fail because meanwhile another test has 'cleared' the test DB.
If I set runTestInSeparateProcess to true, tests passed although they are run very slowly. While it is a problem, the main problem is that in such case if a test fails, then no meaningful error message is displayed - instead, I have "serialization not allowed" error for PDO or SimpleXML objects.

I read a discussion about it and Sebastian Bergmann said:
1) if there is no process isolation, then transactions should be used
2) the "serialization not allowed" error is not an PHPUnit problem
3) DB test cases may use process isolation

None of these helps me.
1) I can not use transactions because I have legacy code and the low level DB object doesn't support nested transactions, while the tested objects use transactions.
2) and 3) I experience the problems described above

Ideas? Similar problems and solutions?

Cheers, Vlad
There are 10 types of people in this world, those who understand binary and those who don't
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: PHPUnit & DatabaseTestCase

Post by josh »

Personally I'd just alter the low level DB object to delegate to your new more robust DB object. Testing legacy code without modifying it isn't always possible.
Post Reply