function index() { $this->unit->run(get_context_domain()->get_host(), 'http://localhost/', '測試get_context_domain()'); $this->unit->run(get_context_domain()->get_id(), 'is_int', '測試get_context_domain() id'); $this->unit->run(get_context_webpage()->get_uri(), '/CodeIgniter_1.7.2/unit_test', '測試get_context_webpage(),應該是得到來自上一個的網頁'); $this->unit->run(get_context_webpage()->get_id(), 'is_int', '測試get_context_webpage() id'); //------------------------------- clear_context_user(); $user = get_context_user(); $this->unit->run(get_class($user), null, '未登入之前測試get_current_user()'); $user = $this->user->create_user($this->url, $this->email); $this->unit->run($user->get_id(), 'is_int', '建立一個' . $this->email . '看看,id有沒有進去'); set_context_user($user); context_complete(); ?> <a href="ut_context/check_user">確認是否有建立好user</a> <?php // $this->unit->run($test_result // , $expected_result // , $test_name); //context_complete(); unit_test_report($this); }
/** * 進行登入的動作 * @version 20140423 wyfan * @param Array $data 準備傳入view的參數 */ private function _check_login($data) { $data["domain"] = $_POST["domain"]; $data['email'] = $_POST['email']; $data['password'] = $_POST['password']; // echo 'check 2: email & password:'******'email'].'&'.$data['password'].'<br>'; //msg 2 // search user data $search_registered_user = $this->user->find_user($data["domain"], $data["email"], $data["password"]); //test_msg("data", $data); //test_msg("search", is_null($search_registered_user) ); // 判斷是否有來源url //if (isset($data['referer_url'])){ // $data['has_url'] = true; //} // 檢查看看是否有已經註冊的使用者 if (isset($search_registered_user)) { // 存入使用者,送出 //$this->load->helper("context"); set_context_user($search_registered_user); context_complete(); return $this->_redirect_to_referer_url(); } else { $data["message"] = $this->lang->line("web_apps.authentication.login_error.user_not_found"); //'電子信箱或是密碼錯誤。' return $this->_show_login_form($data); } }
public function check_auth() { create_context(TRUE); $url = 'http://www.plurk.com/p/6dhwp7'; $email = '*****@*****.**'; $group_name = 'check_auth'; $user = $this->user->create_user($url, $email); $group = $this->group->create_group($url, $group_name); $group->add_actor($user); $annotation = new Annotation(784); $this->authorize_manager->set_resource($annotation); $this->authorize_manager->policy_add_actor(5, $group); clear_context_user(); $search = new Search_annotation_collection(); $count = $search->length(); $this->unit->run($count, 'is_int', '先找看看有沒有,應該是有的'); set_context_user($user); $search = new Search_annotation_collection(); $this->unit->run($search->length(), $count + 1, '設定權限之後,應該能找到被設定的那一個項目'); unit_test_report($this); }
public function check_login($callback) { $output = FALSE; //$action = 1; $action = "login.check.success"; $user_id = NULL; if (login_require(FALSE)) { //表示有登入喔! $user = get_context_user(); set_context_user($user); $output = $this->_parse_user_output($user, FALSE); $user_id = $user->get_id(); } else { $output = $this->_create_default_data(); //$action = 2; $action = "login.check.failed"; } $memo = $this->client_ip; kals_log($this->db, $action, array('memo' => $memo, 'user_id' => $user_id)); context_complete(); return $this->_display_jsonp($output, $callback); }