예제 #1
0
 public static function measure_from()
 {
     ETime::$time_start = microtime(true);
 }
예제 #2
0
 public function test()
 {
     $total_time = 0;
     EStructure::view("header");
     ETime::measure_from();
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     echo '<h3>Sanity OCS test</h3>';
     echo '<p>config..........';
     $check = $client->get("v1/config");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/check..........';
     $postdata = array("login" => "test", "password" => "password");
     $check = $client->post("v1/person/check", $postdata);
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/add..........';
     $postdata = array("login" => "cavolfiore", "password" => "cavolfiore", "email" => "*****@*****.**", "firstname" => "cavolf", "lastname" => "chiappe");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $check = $client->post("v1/person/add", $postdata);
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/data..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/data");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/data?name=cavol&page=1&pagesize=10..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/data?name=cavol&page=1&pagesize=10");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/data/[login]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/data/cavolfiore");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>person/self..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/person/self");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/add..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $postdata = array("name" => "esempio", "type" => "0", "downloadname1" => "downloadname1", "downloadlink1" => "downloadlink1", "description" => "description", "summary" => "summary", "version" => "version", "changelog" => "changelog", "personid" => "test");
     $client->set_auth_info("test", "password");
     $check = $client->post("v1/content/add", $postdata);
     $contentid = $this->example_contentid = $check['ocs']['data']['content'][0]['id'];
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/categories..........';
     $check = $client->get("v1/content/categories");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/licenses..........';
     $check = $client->get("v1/content/licenses");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/data..........';
     $check = $client->get("v1/content/data");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/data?search=esem..........';
     $check = $client->get("v1/content/data?search=esem");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/data/[contentid]..........';
     $check = $client->get("v1/content/data/{$contentid}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/download/[contentid]/1..........';
     $check = $client->get("v1/content/download/{$contentid}/1");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/vote/[contentid]..........';
     $id = intval($contentid);
     $rate = floatval(1);
     $postdata = array("vote" => $rate);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/content/vote/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>content/edit/[contentid]..........';
     $postdata = array("name" => "esempiomod", "summary" => "summarymod", "downloadname1" => "downloadname1mod", "downloadlink1" => "downloadlink1mod", "description" => "descriptionmod", "version" => "versionmod", "changelog" => "changelogmod");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/content/edit/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>[get] activity..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/activity");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>[post] activity..........';
     $postdata = array("message" => "coding is fun");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/activity");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>fan/add..........';
     $postdata = array("idcontent" => $contentid);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/fan/add/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     ETime::measure_from();
     echo '<p>fan/data/[contentid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/fan/data/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>fan/status/[contentid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/fan/status/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>fan/remove..........';
     $postdata = array("idcontent" => $contentid);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/fan/remove/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>comments/add..........';
     $postdata = array("type" => "1", "content" => $id, "content2" => "1", "parent" => "0", "subject" => "subject", "message" => "message");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/comments/add");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>comments/data/[type]/[contentid1]/[contentid2]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     //$client->set_auth_info("test","password");
     $check = $client->get("v1/comments/data/1/{$id}/1&page=1&pagesize=10");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     //deleting content used for tests
     echo '<p>content/delete/[contentid]..........';
     $postdata = array("contentid" => $id);
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/content/delete/{$id}");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     /*
      * TODO: add to OCS specs more returncodes than just 100
      */
     echo '<p>friend/data/[personid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/friend/data/cavolfiore");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     /*
      * TODO: add to OCS specs more returncodes than just 100
      */
     echo '<p>friend/receivedinvitations..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $check = $client->get("v1/friend/receivedinvitations");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     /*
      * TODO: add to OCS specs more returncodes than just 100
      */
     echo '<p>friend/invite/[personid]..........';
     $postdata = array("message" => "would you be my friend?");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("test", "password");
     $client->set_post_data($postdata);
     $check = $client->post("v1/friend/invite/cavolfiore ");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>friend/approve/[personid]..........';
     $postdata = array("message" => "would you be my friend?");
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("cavolfiore", "cavolfiore");
     $client->set_post_data($postdata);
     $check = $client->post("v1/friend/approve/test");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>friend/decline/[personid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("cavolfiore", "cavolfiore");
     $check = $client->post("v1/friend/decline/test");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )";
     echo '<p>friend/cancel/[personid]..........';
     $client = new OCSClient(EConfig::$data["ocs"]["host"]);
     $client->set_auth_info("cavolfiore", "cavolfiore");
     $check = $client->post("v1/friend/cancel/test");
     $this->_statuscode_test($check, $client);
     $time = ETime::measure_to();
     $total_time += $time;
     echo "( {$time} )<br>";
     echo "This OCS test took: {$total_time}";
     EStructure::view("footer");
 }