Example #1
0
 /**
  *  登出
  */
 public function logout()
 {
     $user = get_context_user();
     if (isset($user)) {
         clear_context_user();
         $this->_log();
     }
     redirect($this->_login_path);
 }
Example #2
0
    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);
    }
Example #3
0
 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);
 }
Example #4
0
 public function logout($callback)
 {
     $user = get_context_user();
     $user_id = NULL;
     if (isset($user)) {
         $user_id = $user->get_id();
     }
     kals_log($this->db, 7, array('memo' => $this->client_ip, 'user_id' => $user_id));
     clear_context_user();
     context_complete();
     //$output = $this->_create_default_data();
     /*
             $user = get_context_user();
             $output = FALSE;
             if (is_null($user))
        $output = TRUE;
     */
     $output = $this->_create_default_data();
     $this->_display_jsonp($output, $callback);
 }