So i’m trying to do some testing of a SOAP interface. Specifically at the moment, negative testing.
So my SUCCESS condition is that a SoapFault Exception is thrown.
try-catch works for catching the fault. But is there a mechanism for catching the opposite - that NO exception was thrown?
This sort of thing is why I haven’t missed exceptions when I moved to Go.
$expected = false;
try {
// do your test case
} catch(SoapFault $f) {
if($f) {// check that your fault meets your expected criteria in the if statement
$expected = true
}
} finally {
if (!$expected) {
// throw a new exception or do whatever to let your test case know it failed
}
}
Unfortunately for that particular project i have no control over the environment.
Even so, setExpectedException I dont think would work for the depth of error message (The message to be checked would be at a depth of like… $ex->details->Fault->PGFault->details->errormessage)