<?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>Sun, 26 May 2013 02:12:52 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Stuart Herbert's Blog: ContractLib - An Introduction & Comparing it to PHP's Assert]]></title>
      <guid>http://www.phpdeveloper.org/news/17405</guid>
      <link>http://www.phpdeveloper.org/news/17405</link>
      <description><![CDATA[<p>
<i>Stuart Herbert</i> has two new posts to his blog showing how to use the <a href="https://github.com/stuartherbert/ContractLib">ContractLib</a> tool he's created to define programming "contracts". In <a href="http://blog.stuartherbert.com/php/2012/01/16/getting-started-with-contractlib/">the first</a> he shows some sample usage of the tool and in <a href="http://blog.stuartherbert.com/php/2012/01/17/comparing-contractlib-to-phps-built-in-assert/">the second</a> he compares the functionality of ContractLib's features and PHP's own "<a href="http://us3.php.net/assert">assert</a>" method.
</p>
<blockquote>
<a href="https://github.com/stuartherbert/ContractLib">ContractLib</a> is a simple-to-use PHP component for easily enforcing programming contracts throughout your PHP components. These programming contracts can go a long way to helping you, and the users of your components, develop more robust code.
</blockquote>
<p>
In <a href="http://blog.stuartherbert.com/php/2012/01/16/getting-started-with-contractlib/">his example tests</a> he shows how to set a pre-condition on a method's input ensuring that it will always be the correct datatype (array). In <a href="http://blog.stuartherbert.com/php/2012/01/17/comparing-contractlib-to-phps-built-in-assert/">his comparison</a> with PHP's "assert", he lists out some of the features that either one has and notes that ContractLib allows you to be much more flexible with your checking than just simple statements.
</p>]]></description>
      <pubDate>Tue, 17 Jan 2012 10:58:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP and Me Blog: How to Type Less $this in PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/16028</guid>
      <link>http://www.phpdeveloper.org/news/16028</link>
      <description><![CDATA[<p>
In a recent post to the "PHP and Me" blog they look at how to <a href="http://phpandme.tumblr.com/post/3620995908/how-to-type-less-this-in-phpunit">type less $this</a> in your PHPUnit tests using some handy tricks and a bit of custom code.
</p>
<blockquote>
Lately I've been writing a few tests (using PHPUnit), and when you do there's one thing you end up doing a lot, which is typing $this-> whenever you need to do pretty much anything. It's not that bad (and PHP can be quite verbose itself) but it can become a bit of a bore I guess, especially after a while. [...] Those were valid points [about the global testing functions added to PHPUnit], and for a while that feature was even temporarily removed. So.. now what? Back to typing all those $this-> over & over again? Maybe not.
</blockquote>
<p>
The post shows how to use the included functions to remove the "$this" in something like "$this->assertTrue()" or, to reduce things even more and not pollute the global namespace, a different approach by extending Assert. A few code examples are included as well as the class that extends the normal Assert functionality PHPUnit provides. It allows for the more flexible short-hand function calls to automatically be mapped back to their "more correct" versions.
</p>]]></description>
      <pubDate>Thu, 10 Mar 2011 13:25:51 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Web Builder Zone: PHPUnit 3.5: easier asserting and mocking]]></title>
      <guid>http://www.phpdeveloper.org/news/15195</guid>
      <link>http://www.phpdeveloper.org/news/15195</link>
      <description><![CDATA[<p>
On the Web Builder Zone (part of <a href="http://dzone.com">DZone</a>) <i>Giorgio Sironi</i> has <a href="http://css.dzone.com/articles/phpunit-35-easier-asserting">a new article</a> talking about new features in the latest release of <a href="http://phpunit.de">PHPUnit</a> including one of his own introduction - the MockBuilder to make mocking in tests simpler.
</p>
<blockquote>
The official release of PHPUnit 3.5 is now available for PEAR installation, after a long beta period. PHPUnit 3.5 provides many new features such as a bunch of new assertions methods and annotations, and a little but very useful contribution of mine: the MockBuilder. [...] As you may know, the 3.4 Api contains a getMock() method with 7 arguments. Since some of this arguments are booleans, a call to getMock() can get very obscure if you don't memorize the meaning of all the 7 arguments. [...] The Builder creational pattern is a small layer of abstraction over the instantation process, that [...] gives you a clear Api.
</blockquote>
<p>
He includes a few examples of both the "getMock" function call and its "getMockBuilder" relation. He also includes a full sample class that shows off some of the other new improvements to PHPUnit like new assertions on variables and object attributes, the "instanceof" checks and the MockBuilder once again.
</p>]]></description>
      <pubDate>Tue, 28 Sep 2010 08:46:55 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP Developer Blog: Unit Tests: How to test for Exceptions]]></title>
      <guid>http://www.phpdeveloper.org/news/12374</guid>
      <link>http://www.phpdeveloper.org/news/12374</link>
      <description><![CDATA[<p>
The PHP Developer Blog has <a href="http://www.phpdevblog.net/2009/04/unit-tests-how-to-test-for-exceptions.html">a quick post</a> for the unit testers out there on how to work with exception handling in your tests.
</p>
<blockquote>
When unit testing, you'd also want to test whether your application throws Exceptions as expected (the following examples are based on SimpleTest). Assumption for the examples is, that we have a method that expects an integer as parameter.
</blockquote>
<p>
Putting the assertion inside of the catch block won't work correctly since it wouldn't happen unless an exception is thrown. Instead he recommends putting it right after the exception try/catch and check to see if the exception variable is a type of 'Exception' (with another potential solution of adding in a check for an 'InvalidArgumentException').
</p>]]></description>
      <pubDate>Mon, 20 Apr 2009 12:06:15 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David Otton's Blog: php://memory, Unit Tests]]></title>
      <guid>http://www.phpdeveloper.org/news/11425</guid>
      <link>http://www.phpdeveloper.org/news/11425</link>
      <description><![CDATA[<p>
In looking to test his <a href="http://www.otton.org/2008/11/17/fputcsv-implementation-in-php/">fputscsv</a> functionality, <i>David Otton</i> found a simple way to measure its performance by using streams.
</p>
<blockquote>
Then I realised I could use PHP's (fairly) new IO streams to dump the function's output to a temporary buffer, and read it back in for comparison. Not perfect, but it removes concerns about file mutexes, permissions, unique filenames, etc. and speeds up the tests, as they never touch disc.
</blockquote>
<p>
He uses a custom stream and points it to php://memory to store and read the data from. Code is included in the post as well as example usage. It runs an assert that the value pushed into another memory chunk is the same as the first one (ensuring that the results of his fputcsv calls are valid).
</p>]]></description>
      <pubDate>Tue, 18 Nov 2008 15:42:01 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Getting Started with Hamcrest]]></title>
      <guid>http://www.phpdeveloper.org/news/9384</guid>
      <link>http://www.phpdeveloper.org/news/9384</link>
      <description><![CDATA[<p>
Following up on the <a href="http://www.phpdeveloper.org/news/9337">start of his port</a> of the Hamcrest (a library of "matchers") functionality over to PHP, <i>Sebastian Bergmann</i> has posted <a href="http://sebastian-bergmann.de/archives/735-Getting-Started-with-Hamcrest.html">the getting started guide</a> to show you how to use it with the popular <a href="http://www.phpunit.de/">PHPUnit</a> unit testing software.
</p>
<blockquote>
There are a number of situations where matchers are invaluble, such as UI validation, or data filtering, but it is in the area of writing flexible tests that matchers are most commonly used.
</blockquote>
<p>
His <a href="http://sebastian-bergmann.de/archives/735-Getting-Started-with-Hamcrest.html">example</a> that checks to see if one object is equal to another object. The Hamcrest matcher allows for a "assertThat" method making it easier to create and use pre-existing unit testing assertions.
</p>
<p>
He also includes a list of some of the most common matchers broken up into groups of core, logical, object, number and text.
</p>]]></description>
      <pubDate>Wed, 09 Jan 2008 10:23:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Tony Freixas's Blog: High-performance debugging]]></title>
      <guid>http://www.phpdeveloper.org/news/8733</guid>
      <link>http://www.phpdeveloper.org/news/8733</link>
      <description><![CDATA[<p>
<i>Tony Freixas</i> has <a href="http://www.tigerheron.com/article/2007/09/high-performance-debugging">posted a new article</a> covering his thoughts on high-performance debugging with PHP5:
</p>
<blockquote>
In this article, I will show you how to use PHP 5 input filters to support debug, trace and assert statements so that a one-line change disables these statements and restores your script to full production performance.
</blockquote>
<p>
He makes a custom solution, a simple method for just outputting simple debug statements via his own custom debugging classes - thDebug, theTrace and thAssert. He wraps all of these in a thDebugManager class to make them all play nice together.
</p>
<p>
With these in place, he moves on to the real key to the debugger, using the input filter extension that comes with PHP5. He makes a thAbstractStreamFilter abstract class to base the filtering on and, using this interface, makes his thDebugFilter class to handle the various debugging outputs. He uses the __autoload functionality to load it correctly into each page that needs it.
</p>]]></description>
      <pubDate>Wed, 26 Sep 2007 12:59:00 -0500</pubDate>
    </item>
  </channel>
</rss>
