public function testAccessTokenError() { $mockResponse = $this->getMockBuilder('Widop\\HttpAdapter\\HttpResponse')->disableOriginalConstructor()->getMock(); $mockResponse->method('getBody')->will($this->returnValue(json_encode(['tokenResponse' => ['errorCode' => 999, 'errorMessage' => 'error']]))); $this->setExpectedException('RequestLab\\Estat\\EstatException'); $this->httpAdapterMock->expects($this->once())->method('getContent')->will($this->returnValue($mockResponse)); $this->client->getAccessToken(); }
/** * @expectedException \RequestLab\Estat\EstatException */ public function testQueryWithJsonError() { $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(array('content'))); $this->httpAdapterMock->expects($this->once())->method('postContent')->with('https://ws.estat.com/gosu/rest/data/json', array('Content-Type' => 'application/json'), $this->equalTo(array('content')))->will($this->returnValue(json_encode(array('gosuResponse' => array('errorCode' => '999', 'errorMessage' => 'error'))))); $this->service->query($this->queryMock); }