classOAuth = new OAuth2StorageUserCredential(); $_SESSION['wallet']['user']['uid'] = $this->user; $_SESSION['wallet']['user']['password'] = $this->pass; //insere access token $this->classOAuth->setAccessToken($this->accessToken, $this->client_id, $this->user_id, (time() + 3600), 'all', $this->refreshToken); //insere refresh token $this->classOAuth->setRefreshToken($this->refreshToken, $this->client_id, $this->user_id, (time() + 3600), 'all'); $this->curlOPT = array( CURLOPT_URL => $this->url, CURLOPT_HEADER => 0, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_TIMEOUT => 4 , CURLOPT_HTTPHEADER => array( 'Authorization: OAUTH Bearer aaaaaa259f553ac148f01b6bbcbb101')); } public $provider= array( array( 1332877974, 'teste de aplicação 1', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 2', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 3', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 4', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 5', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 6', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 7', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 8', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 9', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 10', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1), array( 1332877974, 'teste de aplicação 11', 'php unit teste', '
Teste de funcionamento
', '0', 2147483647, 1, 1) ); public function testcreateResource() { foreach($this->provider as $key => $value){ Controller::service('PostgreSQL')->execResultSql( "INSERT INTO phpgw_news (news_date,news_subject, news_submittedby, news_content, news_begin, news_end, news_cat, is_html)VALUES('".$value[0]."', '".$value[1]."', '".$value[2]."','".$value[3]."','".$value[4]."','".$value[5]."', '".$value[6]."', '".$value[7]."')"); } //Controller::service('PostgreSQL')->commit(); } public function testCheckMaxResource() { $c = curl_init(); curl_setopt_array($c, $this->curlOPT); $r = curl_exec($c); curl_close($c); $body = json_decode($r,true); $this->assertCount(10, $body); } public function testCheckResource() { $c = curl_init(); curl_setopt_array($c, $this->curlOPT); $r = curl_exec($c); curl_close($c); $body = json_decode($r,true); foreach($body as $key => $value){ $this->assertArrayHasKey('subject', $body[$key]); $this->assertArrayHasKey('content', $body[$key]); $this->assertArrayHasKey('startTime', $body[$key]); $this->assertArrayHasKey('endTime', $body[$key]); $this->assertArrayHasKey('id', $body[$key]); $this->assertArrayHasKey('subject', $body[$key]); } } public function testCheckFinish() { $c = curl_init(); curl_setopt_array($c, $this->curlOPT); $r = curl_exec($c); curl_close($c); $body = json_decode($r,true); $countCurrent = count($body) - 9; Controller::service('PostgreSQL')->execResultSql( "DELETE FROM phpgw_news where news_submittedby = 'php unit teste'"); $c = curl_init(); curl_setopt_array($c, $this->curlOPT); $r = curl_exec($c); curl_close($c); $body = json_decode($r,true); $this->assertCount($countCurrent , $body); } public function tearDown() { $this->classOAuth->unsetRefreshToken($this->refreshToken); $this->classOAuth->unsetAccessToken($this->accessToken); } } ?>