<?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>Mon, 20 May 2013 13:31:00 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Kurt Payne's Blog: How to Unit Test pcntl_fork()]]></title>
      <guid>http://www.phpdeveloper.org/news/17421</guid>
      <link>http://www.phpdeveloper.org/news/17421</link>
      <description><![CDATA[<p>
<i>Kurt Payne</i> has a new post to his blog showing how you can <a href="http://kpayne.me/2012/01/17/how-to-unit-test-fork/">unit test your process forking</a> in your PHP application (<a href="http://php.net/pcntl">pcntl</a>).
</p>
<blockquote>
At some point, many php developers turn to the pcntl functions in php to write a daemon, or server, or simulate threading. But how do you unit test this with complete code coverage? [...] We need to engage some black arts php extensions to make this happen.  An installation guide follows, and the post ends with a complete listing of the unit test.
</blockquote>
<p>
He uses the <a href="https://github.com/sebastianbergmann/php-test-helpers">test_helpers</a> extension (as provided by <i>Sebastian Bergmann</i>) and <a href="https://github.com/zenovich/runkit/">Runkit</a> to allow the test to define new methods copying the current pcntl methods and mocks up the responses. Tests are included to check the parent of a process, checking the children of a process and testing that a fork could be made. Hes's even included <a href="http://kurtpayne.files.wordpress.com/2012/01/forktest_code_coverage.png?w=614&h=464">visual proof</a> of this working.
</p>]]></description>
      <pubDate>Thu, 19 Jan 2012 13:40:20 -0600</pubDate>
    </item>
  </channel>
</rss>
