Page 1 of 1

sharedFixture

Posted: Mon Nov 03, 2008 11:54 am
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?