public function testSuccessCall() { $implMock = $this->getMock("Seven\\RpcBundle\\Rpc\\Implementation"); $transportMock = $this->getMock("Seven\\RpcBundle\\Rpc\\Transport\\TransportInterface"); $httpRequestMock = $this->getMock("Symfony\\Component\\HttpFoundation\\Request"); $httpResponseMock = $this->getMock("Symfony\\Component\\HttpFoundation\\Response"); $methodReturnMock = $this->getMock("Seven\\RpcBundle\\Rpc\\Method\\MethodReturn"); $client = new Client("http://webservice.url/path", $implMock, $transportMock); $implMock->expects($this->once())->method("createHttpRequest")->with($this->callback(function (MethodCall $methodCall) { return $methodCall->getMethodName() == "method.name" && $methodCall->getParameters() == array('param_1', 'param_2'); }))->will($this->returnValue($httpRequestMock)); $transportMock->expects($this->once())->method("makeRequest")->will($this->returnValue($httpResponseMock)); $implMock->expects($this->once())->method("createMethodResponse")->with($this->equalTo($httpResponseMock))->will($this->returnValue($methodReturnMock)); $methodReturnMock->expects($this->once())->method("getReturnValue")->will($this->returnValue("return_value")); $this->assertEquals('return_value', $client->call("method.name", array('param_1', 'param_2'))); }
public function __construct($webServiceUrl, TransportInterface $transport = null) { parent::__construct($webServiceUrl, new Implementation(), $transport); }