作者:优雅的鼻涕泡 | 来源:互联网 | 2023-09-08 12:01
ImtryingtomockSoapClientwiththefollowingcode:我试图用以下代码模拟SoapClient:$soapClientMock$this
Im trying to mock SoapClient with the following code:
我试图用以下代码模拟SoapClient:
$soapClientMock = $this->getMockBuilder('SoapClient')
->disableOriginalConstructor()
->getMock();
$soapClientMock->method('getAuthenticateServiceSettings')
->willReturn(true);
This will not work since Phpunit mockbuilder does not find the function getAuthenticateServiceSettings. This is a Soap function specified in the WSDL.
这不起作用,因为Phpunit mockbuilder没有找到函数getAuthenticateServiceSettings。这是WSDL中指定的Soap函数。
However, if i extend the SoapClient class and the getAuthenticateServiceSettings method it does work.
但是,如果我扩展SoapClient类和getAuthenticateServiceSettings方法,它确实有效。
The problem is i have 100s of SOAP calls, all with their own parameters etc. so i dont want to mock every single SOAP function and more or less recreate the whole WSDL file...
问题是我有100多个SOAP调用,都有自己的参数等。所以我不想模拟每个SOAP函数,或多或少地重新创建整个WSDL文件...
Is there a way to mock "magic" methods?
有没有办法模仿“魔法”方法?
3 个解决方案