So I am trying to setup a Behat scenario that lets me test when a soap calls fails authentication. I just need to be able to test this step and then move onto other testing steps. Well I am specifically testing a call to a SOAP service without authentication (the service requires HTTP Auth). When I do this it generates a PHP Fatal error and then kills the script.
So far I have tried using "@" to suppress the error and calling error_reporting(0) to turn off error reporting during that part of the test. But it still kills the script. Is there any way around this?
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);
}
Here is the error:
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from
Any way around this?