sharedFixture

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
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

sharedFixture

Post by koen.h »

I'm having a hard time finding out how to share my db connection. The phpunit manual addresses this topic but I don't know enough about phpunit to know how to implement it. Or I'm just not getting it.

Let's take this code:

Code: Select all

 
class Lib_AllTests extends PHPUnit_Framework_TestSuite {
    protected function setUp() {
        $this->sharedFixture = *mydatabaseconnection*; 
    }
    public static function main() {
        PHPUnit_TextUI_TestRunner::run(self::suite());
    }
    public static function suite() {
        $suite = new PHPUnit_Framework_TestSuite('My Library');
        $suite->addTest(Lib_Package_AllTests::main());
        return $suite;
    }
}
 
The manual says this should be enough to have the sharedFixture available in the other tests (Lib_Package_AllTests). But it doesn't work.

What am I missing here?
Post Reply