Beispiel #1
0
 function index()
 {
     $scope1 = $this->scope->create_scope(0, 2);
     $scope2 = $this->scope->create_scope(6, 9);
     $coll = new Annotation_scope_collection();
     $coll->set_scopes($scope1);
     $this->unit->run($coll->get_scope_length(), 3, "set_scopes 0~2之後測試get_scope_length()");
     $coll->set_scopes($scope2);
     $this->unit->run($coll->get_scope_length(), 4, "set_scopes 6~9之後測試get_scope_length()");
     $coll->add_scope($scope1);
     $this->unit->run($coll->get_scope_length(), 7, "add_scopes 0~2之後測試get_scope_length() (0~2 6~9)");
     $this->unit->run($coll->length(), 2, "add_scopes 0~2之後測試get_scopes() (0~2 6~9)");
     $scope3 = $this->scope->create_scope(5, 7);
     $coll->add_scope($scope3);
     $this->unit->run($coll->get_scope_length(), 8, "add_scopes 5~7之後測試get_scope_length() (0~2 5~9)");
     $this->unit->run($coll->length(), 2, "add_scopes 5~7之後測試get_scopes() (0~2 5~9)");
     $scope = $this->scope->create_scope(3, 4);
     $coll->exclude_scope($scope);
     $this->unit->run($coll->get_scope_length(), 8, "exclude_scopes 3~4之後測試get_scope_length() (0~2 5~9)");
     $this->unit->run($coll->length(), 2, "exclude_scopes 3~4之後測試get_scopes() (0~2 5~9)");
     $scope = $this->scope->create_scope(4, 5);
     $coll->exclude_scope($scope);
     $this->unit->run($coll->get_scope_length(), 7, "exclude_scopes 4~5之後測試get_scope_length() (0~2 6~9)");
     $this->unit->run($coll->length(), 2, "exclude_scopes 3~4之後測試get_scopes() (0~2 6~9)");
     $scope = $this->scope->create_scope(7, 8);
     $coll->exclude_scope($scope);
     $this->unit->run($coll->get_scope_length(), 5, "exclude_scopes 7~8之後測試get_scope_length() (0~2 6 9)");
     $this->unit->run($coll->length(), 3, "exclude_scopes 7~8之後測試get_scopes() (0~2 6 9)");
     //來測試foreach吧!!
     foreach ($coll as $key => $scope) {
         $this->unit->run_false($scope->get_length(), 999, "測試foreach,看scope " . $key . " 是否都有正確底顯示");
     }
     //        $this->unit->run($test_result
     //                , $expected_result
     //                , $test_name);
     unit_test_report($this);
 }
 public function create_scope($from, $to, $anchor_text_id = NULL, $webpage = NULL)
 {
     $this->_CI_load('library', 'scope/Annotation_scope', 'annotation_scope');
     $scope = new Annotation_scope();
     $scope->set_index($from, $to);
     if (NULL != $anchor_text_id) {
         $scope->set_anchor_text($anchor_text_id);
     }
     if (isset($webpage)) {
         $scope->set_webpage($webpage);
     }
     $coll = new Annotation_scope_collection();
     $coll->set_scopes(array($scope));
     return $coll;
 }