예제 #1
0
 public function testAccessTokenError()
 {
     if (!function_exists('openssl_x509_read')) {
         $this->markTestSkipped('The "openssl_x509_read" function is not available.');
     } else {
         $this->setExpectedException('Widop\\GoogleAnalytics\\GoogleAnalyticsException');
     }
     $this->httpAdapterMock->expects($this->once())->method('postContent')->will($this->returnValue(json_encode(array('error' => 'error'))));
     $this->client->getAccessToken();
 }
예제 #2
0
 /**
  * @expectedException \RequestLab\XitiAnalytics\XitiException
  */
 public function testQueryWithJsonError()
 {
     $this->clientMock->expects($this->once())->method('getHeaders')->will($this->returnValue(array('Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($this->login . ':' . $this->password))));
     $this->queryMock->expects($this->once())->method('build')->will($this->returnValue('uri'));
     $this->httpAdapterMock->expects($this->once())->method('getContent')->with($this->equalTo('uri'))->will($this->returnValue(json_encode(array('ErrorCode' => '2017', 'ErrorMessage' => 'Le message'))));
     $this->service->query($this->queryMock);
 }
예제 #3
0
 /**
  * @expectedException \Widop\GoogleAnalytics\GoogleAnalyticsException
  */
 public function testQueryWithHtmlError()
 {
     $this->clientMock->expects($this->once())->method('getAccessToken')->will($this->returnValue('token'));
     $this->queryMock->expects($this->once())->method('build')->with($this->equalTo('token'))->will($this->returnValue('uri'));
     $this->httpAdapterMock->expects($this->once())->method('getContent')->with($this->equalTo('uri'))->will($this->returnValue('<html></html>'));
     $this->service->query($this->queryMock);
 }