/** * @covers ::dbClose */ public function test_dbClose_closingTwice() { $this->driver->dbClose(); $this->driver->dbClose(); // To satisfy PHPUnit $this->assertTrue(true); }
/** * Database factory. * * It returns the same instance for the same config. * * @see \Kicaj\Tools\Itf\DbConnect * * @param array $dbConfig The database configuration. * * @throws SchemaException * * @return Db */ public static function factory(array $dbConfig) { $key = md5(json_encode($dbConfig)); if (isset(self::$instances[$key])) { return self::$instances[$key]; } switch (DbConnect::getDriver($dbConfig[Schema::CONFIG_KEY_CONNECTION])) { case DbConnector::DB_DRIVER_MYSQL: $driver = new MySQL(); break; default: throw new SchemaException('Unknown database driver name: ' . DbConnect::getDriver($dbConfig[Schema::CONFIG_KEY_CONNECTION])); } $driver->dbSetup($dbConfig[Schema::CONFIG_KEY_CONNECTION])->dbConnect(); self::$instances[$key] = new self($driver); return self::$instances[$key]; }