<?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>Thu, 23 May 2013 19:44:44 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[VG Tech Blog: Unit Testing with Streams in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17229</guid>
      <link>http://www.phpdeveloper.org/news/17229</link>
      <description><![CDATA[<p>
On the VG Tech blog today there's a new post from <i>Andr&eacute; Roaldseth</i> about using <a href="http://phpunit.de">PHPUnit</a> to <a href="http://tech.vg.no/2011/06/27/unit-testing-with-streams-in-php/">test PHP streams</a>, basing the assertions on the data rather than the functionality itself.
</p>
<blockquote>
Using the memory/temporary stream provided by php:// stream wrapper you  can create a stream with read and write access directly to RAM or to a temporary file [using "php://memory"]. This gives you the possibilty to write unit tests that does not rely on a specific file, resource or stream, but rather on data provided by the test itself.
</blockquote>
<p>
There's no specific code examples here, but you can refer to the <a href="http://us3.php.net/manual/en/wrappers.php.php">stream wrappers</a> section of the PHP manual for more details on this and other handy built-in streams. Once created, it can then be used just as <a href="http://no.php.net/manual/en/book.stream.php">any other stream resource</a> can. This could be useful to provide mocks in your testing, replacing any other stream-able resource with a "memory" or "temp" placeholder.
</p>]]></description>
      <pubDate>Thu, 08 Dec 2011 09:13:28 -0600</pubDate>
    </item>
  </channel>
</rss>
