public function getCloudStackMock($serviceName = null, $callback = null)
{
$me = $this;
$serviceInstance = null;
$csStub = $this->getMock(self::CLOUDSTACK_NS . '\\CloudStack', array('__get', 'getClient'), array('fakeEndpoint', 'fakeApiKey', 'fakeSecretKey', self::PLATFORM));
$queryClientClass = self::CLOUDSTACK_NS . '\\Client\\QueryClient';
$queryClientStub = $this->getMock($queryClientClass, array('call'), array('fakeEndPoint', 'fakeApiKey', 'fakeSecretKey', self::PLATFORM));
if (is_string($callback)) {
$mth = $callback;
$callback = function () use($me, $mth) {
return $me->getQueryClientResponseMock($me->getFixtureFileContent($mth), null);
};
} else {
if (!is_callable($callback)) {
throw new \InvalidArgumentException('Invalid callback');
}
}
$queryClientStub->expects($this->any())->method('call')->will($this->returnCallback($callback));
$csStub->expects($this->any())->method('getClient')->will($this->returnValue($queryClientStub));
if ($serviceName !== null) {
$serviceInstance = $this->getServiceInterfaceMock($serviceName, $csStub);
}
$csStub->expects($this->any())->method('__get')->will($this->returnValue($serviceInstance));
return $csStub;
}