class MyTestCase extends PHPUnit_Framework_TestCase { public static function setUpBeforeClass() { // Connect to database $db = new PDO('mysql:host=localhost;dbname=mydb', 'username', 'password'); // Set DB connection as a class property self::$db = $db; } public function testDatabaseConnection() { $this->assertInstanceOf(PDO::class, self::$db); } }In this example, the setUpBeforeClass() method sets up a database connection and stores it as a static property of the test case class. The test case then has access to this resource in all its tests. Package/Library: PHPUnit.