Scalr\Tests\Service\AwsTestCase::getQueryClientResponseMock PHP Method

getQueryClientResponseMock() public method

Gets QueryClientResponse Mock.
public getQueryClientResponseMock ( string $body, integer $responseCode = null, Aws $awsStub = null ) : Scalr\Service\Aws\Client\QueryClientResponse
$body string
$responseCode integer optional The code of the http response
$awsStub Scalr\Service\Aws optional Aws mock
return Scalr\Service\Aws\Client\QueryClientResponse Returns response mock object
    public function getQueryClientResponseMock($body, $responseCode = null, $awsStub = null)
    {
        $response = $this->getMock(AwsTestCase::AWS_NS . '\\Client\\QueryClientResponse', array('getRawContent', 'getResponseCode'), array($this->getMock('\\http\\Client\\Response')));
        if ($awsStub !== null) {
            $response->setQueryNumber(++$awsStub->queriesQuantity);
        }
        if ($responseCode === null) {
            if (preg_match('/<\\/errors>/i', $body)) {
                $responseCode = 500;
            } else {
                $responseCode = 200;
            }
        }
        $response->expects($this->any())->method('getResponseCode')->will($this->returnValue($responseCode));
        $response->expects($this->any())->method('getRawContent')->will($this->returnValue($body));
        return $response;
    }