title: Phpunit - mocking SoapFault->getMessage()
body: <p>I'm connecting to a <a href="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" rel="nofollow">third party service</a> using SOAP. This service will return SoapFaults some times. Because this is expected, I want to test this, by mocking the SoapFaults. There are five standard SoapFaults it will return.</p>
  
  <p>Here is the start of a real SoapFault:</p>
  
  <pre><code>object(SoapFault)#7 (11) {
    ["message":protected]=&gt;
    string(19) "{ 'INVALID_INPUT' }"
  </code></pre>
  
  <p>I am interested in this message. In my code I use $e->getMessage().</p>
  
  <pre><code>catch (SoapFault $e)
  {
      // Catch any Soap faults and convert to an error message
      switch ($e-&gt;getMessage())
      {
          case "{ 'INVALID_INPUT' }":
              $this-&gt;addError(self::INVALID_INPUT);
              return FALSE;
  </code></pre>
  
  <p>but I cannot figure out how to mock the SoapClient response. The SoapClient object doesn't appear to take in any input to set the message, and the method <code>getMessage()</code> is final, so I can't mock it.</p>
  
  <p>Any ideas would be appreciated. Thanks.</p>