/** * Gets the default database connection (PHPUnit uses this during setup) * * @return object PHPUnit_Extensions_Database_DB_IDatabaseConnection */ public function getConnection() { // Only get the connection once per test if (is_null($this->connection)) { // Only create the pdo object once per file if (is_null(self::$pdo)) { $filename = with(new \ReflectionClass(get_called_class()))->getFileName(); self::$pdo = new \PDO('sqlite:' . dirname($filename) . DS . 'Fixtures' . DS . $this->fixture); } $this->connection = $this->createDefaultDBConnection(self::$pdo, 'main'); } return $this->connection; }
/** * Resets the database handle to ensure it doesn't cause * problems for subsequent tests * * @return void */ public static function tearDownAfterClass() { self::$pdo = null; }