/** * * @param SC_Query $objQuery * @return Auth_OpenID_Consumer */ function getConsumer(SC_Query $objQuery, $store = "") { switch ($store) { case "Auth_OpenID_MDB2Store": // $store = new Auth_OpenID_FileStore ( MASTER_DATA_REALDIR ); GC_Utils_Ex::gfPrintLog('生成 : Auth_OpenID_MDB2Store'); $store = new Auth_OpenID_MDB2Store($objQuery->conn); if (is_null($this->getMode())) { $store->createTables(); } default: $store = new Auth_OpenID_DumbStore(AUTH_MAGIC); } GC_Utils_Ex::gfPrintLog('生成 : Auth_OpenID_Consumer'); $consumer = new Auth_OpenID_Consumer($store); return $consumer; }
function test_mdb2store() { // The MDB2 test can use any database engine. MySQL is chosen // arbitrarily. if (!(extension_loaded('mysql') || function_exists('dl') && @dl('mysql.' . PHP_SHLIB_SUFFIX)) || !@(include_once 'MDB2.php')) { print "(not testing MDB2 store)"; $this->pass(); return; } require_once 'Auth/OpenID/MDB2Store.php'; global $_Auth_OpenID_db_test_host; $dsn = array('phptype' => 'mysql', 'username' => 'openid_test', 'password' => '', 'hostspec' => $_Auth_OpenID_db_test_host); $db =& MDB2::connect($dsn); if (PEAR::isError($db)) { print "MySQL database connection failed: " . $db->getMessage(); $this->pass(); return; } $temp_db_name = _Auth_OpenID_getTmpDbName(); $result = $db->query("CREATE DATABASE {$temp_db_name}"); if (PEAR::isError($result)) { $this->pass("Error creating MySQL temporary database: " . $result->getMessage()); return; } $db->query("USE {$temp_db_name}"); $store = new Auth_OpenID_MDB2Store($db); if (!$store->createTables()) { $this->fail("Failed to create tables"); return; } $this->_testStore($store); $this->_testNonce($store); $this->_testNonceCleanup($store); $db->query("DROP DATABASE {$temp_db_name}"); }