因此,我正在尝试设置一个 Behat 场景,让我可以测试肥皂调用何时未能通过身份验证。我只需要能够测试这一步,然后进入其他测试步骤。好吧,我正在专门测试对没有身份验证的 SOAP 服务的调用(该服务需要 HTTP Auth)。当我这样做时,它会生成一个 PHP 致命错误,然后终止脚本。
到目前为止,我已经尝试使用“@”来抑制错误并调用 error_reporting(0) 以在该部分测试期间关闭错误报告。但它仍然会杀死脚本。有没有办法解决?
public function iConnectToASoapServiceAt($soapURL) {
$this->soapURL = $soapURL;
$errorReporting = error_reporting(); //Save the current error reporting level
error_reporting(0); //Turn off error reporting before we try this
try {
$this->client = @new Zend\Soap\Client($soapURL, $this->options);
$this->soapFunctions = $this->client->getFunctions();
}
catch (\Exception $e) {
#For testing when it fails we cannot actually throw an error here.
#throw new Exception("Error connecting to SOAP server.");
}
error_reporting($errorReporting);
}
这是错误:
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from
有什么办法吗?