<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 19 Jun 2013 10:47:18 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Matt Frost: Mocking SoapClient]]></title>
      <guid>http://www.phpdeveloper.org/news/18932</guid>
      <link>http://www.phpdeveloper.org/news/18932</link>
      <description><![CDATA[<p>
<i>Matt Frost</i> has <a href="http://shortwhitebaldguy.com/blog/2012/12/mocking-soapclient">shared some of his work</a> he's done with the <a href="http://php.net/soap">SoapClient</a> in PHP and how he mocked it out for his unit tests (since it's an external resource).
</p>
<blockquote>
The concept of mocking web services for testability took a little while to sink in for me. A big part of it was that my job doesn't see me consuming web services all that often, but I had an opportunity to give it a shot with SOAP. I found that I learned a lot more about testing in general having worked through this. I used SoapClient and wrapped it, so here's a little bit about some of things I learned. Hopefully you don't have to work with SOAP, but if you do you can test it pretty easily.
</blockquote>
<p>
He walks through the mocking of the client itself and how he handled it's ability to translate function calls into SOAP method calls (using "__call") and how he mocked that. He also makes the suggestion that you actually wrap the SoapClient inside of another class rather than trying to mock the actual SoapClient. He also touches on the testing of exceptions that might be thrown by the service and how he tested those using his wrapper class.
</p>]]></description>
      <pubDate>Fri, 21 Dec 2012 10:23:02 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Danne Lundqvist's Blog: SOAP structures in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/11339</guid>
      <link>http://www.phpdeveloper.org/news/11339</link>
      <description><![CDATA[<p>
<i>Danne Lundqvist</i> is <a href="http://www.dotvoid.com/2008/10/soap-structures-in-php/">frustrated with the SOAP functionality</a> that comes native with PHP on one very specific subject - its handling of SOAP structures.
</p>
<blockquote>
Handling SOAP structures in PHP can sometimes be really annoying. If an interface is defined in the WSDL as returning an array I can't be sure that I will get an array. If there is only one element in the array PHP tries to be clever and turn the wanted array into an object which, too me, isn't really smart. I don't know if this is a problem/limitation on the client side, server side or if it is just me doing something stupid in the wsdl.
</blockquote>
<p>
He gives an example of the WSDL that was requested and the differing results from a call that returned one Map item verses several (how the objects were returned). In asking for help, it looks like he got some in the comments - an attribute called SOAP_SINGLE_ELEMENT_ARRAYS that can be added to the configuration array when creating the SoapClient object.
</p>]]></description>
      <pubDate>Tue, 04 Nov 2008 09:33:14 -0600</pubDate>
    </item>
  </channel>
</rss>
