Page 2 of 2

Posted: Sun Aug 07, 2005 8:11 pm
by nielsene
Back to the database unit/web subclasses.

I need the similar subclass in both unit and web trees. Is there any non-repetitive way to subclass both with the same additions? (Short of hacking the simpletest base classes)

I tried to migrate the common code out to an include file and then include that file within the body of the class, but tha's not allowed syntacicly....

Posted: Sun Aug 07, 2005 9:39 pm
by McGruff
Rather than using inheritance, instantiate a "DatabaseUnitTestCase" object in the test case:

Code: Select all

$this->sandbox =& new DatabaseSandbox;
..and call sandbox setUp/tearDown in the test case setUp/tearDown methods.

Inheritance often leads you into problems exactly like this one.

Posted: Tue Aug 09, 2005 1:10 pm
by nielsene
McGruff wrote:Rather than using inheritance, instantiate a "DatabaseUnitTestCase" object in the test case:

Code: Select all

$this->sandbox =& new DatabaseSandbox;
..and call sandbox setUp/tearDown in the test case setUp/tearDown methods.

Inheritance often leads you into problems exactly like this one.
I had started with that but it wasn't working. I think I can go back to it now that I've identified the other "hidden" method calls for setting up some test cases (inlining parts of invoke/run).