Ejemplo n.º 1
0
 function index()
 {
     $url = $this->url;
     $webpage = $this->webpage->create($url);
     $tutor = $webpage->get_tutor();
     $annotation = new Annotation(1017);
     $user = $annotation->get_user();
     $unread_count = $user->get_unread_notification_count();
     $this->unit->run($unread_count, 'is_int', '先看一下user的未讀通知有幾封');
     $tutor->setup_recommend($annotation);
     $recommend = $annotation->get_recommend();
     $this->unit->run($recommend->get_id(), 'is_int', '有取得建議');
     $recommend_annotation = $recommend->get_recommend_by();
     $this->unit->run($recommend_annotation, NULL, '沒有推薦標註');
     $tips = $recommend->get_tips_text_array();
     $this->unit->run_false(count($tips), 0, '有建議');
     //------------------------------------------------
     $recommend_annotation = new Annotation(783);
     $recommend_annotation->set_score(0, 3);
     $recommend_annotation->update();
     $scope = new Annotation_scope(129);
     $recommend_scope = new Annotation_scope_collection();
     $recommend_scope->add_scope($scope);
     $annotation->set_recommend_scopes($recommend_scope);
     $tutor->setup_recommend($annotation);
     $recommend->reload();
     $recommend_annotation = $recommend->get_recommend_by();
     $this->unit->run($recommend_annotation->get_id(), 783, '有找到推薦標註');
     $this->unit->run($user->get_unread_notification_count(TRUE), $unread_count + 2, '因為新增了兩次推薦,所以應該有兩封通知?');
     //        $this->unit->run($test_result
     //                , $expected_result
     //                , $test_name);
     //context_complete();
     unit_test_report($this, __METHOD__);
 }
Ejemplo n.º 2
0
 function time2()
 {
     $id = 783;
     $text2 = '變項太多,這回歸的組合也不知道要排到什麼時候orz';
     $annotation = new Annotation(783);
     $this->unit->run($annotation->get_field('create_timestamp'), 'is_string', 'create_timestamp');
     $this->unit->run($annotation->get_field('update_timestamp'), 'is_string', 'update_timestamp');
     $this->unit->run_false(substr($annotation->get_field('create_timestamp'), 0, 19), substr($annotation->get_field('update_timestamp'), 0, 19), 'create_timestamp == update_timestamp');
     sleep(5);
     $annotation->set_note($text2);
     $annotation->update();
     $annotation->reload();
     $this->unit->run($annotation->get_field('create_timestamp'), 'is_string', 'create_timestamp');
     $this->unit->run($annotation->get_field('update_timestamp'), 'is_string', 'update_timestamp');
     $this->unit->run_false(substr($annotation->get_field('create_timestamp'), 0, 19), substr($annotation->get_field('update_timestamp'), 0, 19), 'create_timestamp != update_timestamp');
     context_complete();
     unit_test_report($this);
 }
Ejemplo n.º 3
0
 public function create_annotation($user_id, $scope_coll, $do_update = TRUE)
 {
     $this->_load_user();
     $user_id = $this->CI->user->filter_id($user_id);
     $annotation = new Annotation();
     $annotation->set_scopes($scope_coll);
     $annotation->set_user($user_id);
     if ($do_update) {
         $annotation->update();
     }
     if (is_null($annotation->get_id())) {
         show_error("Annotation create fail. scope_coll: " . $scope_coll . "; user_id: " . $user_id);
     }
     return $annotation;
 }