<?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>Sat, 25 May 2013 00:40:08 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Zumba Engineering Blog: Mocking Singleton PHP classes with PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/18801</guid>
      <link>http://www.phpdeveloper.org/news/18801</link>
      <description><![CDATA[<p>
On the Zumba Engineering blog today <i>Chris Taylor</i> has a new post about <a href="http://engineering.zumba.com/2012/11/26/singleton-class-phpunit-mocking/">mocking in PHPUnit</a>, specifically how to handle those pesky Singleton methods lurking around your codebase.
</p>
<blockquote>
In many of our projects, utilities and vendor classes are implemented with a <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a>. [...] In this post, we'll cover a nice way to inject a PHPUnit mock object for use in testing methods that utilize singleton classes.
</blockquote>
<p>
He starts by introducing mocking and how to use mock classes in PHPUnit with a simple "sayHello" example. Adding on another layer, he creates a "SomeclassMock" class, defining its own "expects" and "cleanup" methods. This class forces the Singleton method to act more like a regular non-static method and "resets" it after each use.
</p>]]></description>
      <pubDate>Mon, 26 Nov 2012 09:51:04 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP-Coding-Practices.com: Making CakePHP's Pagination work with Model::expects()]]></title>
      <guid>http://www.phpdeveloper.org/news/8526</guid>
      <link>http://www.phpdeveloper.org/news/8526</link>
      <description><![CDATA[<p>
<i>Tim Koschuetzki</i> has posted <a href="http://php-coding-practices.com/cakephp-specific/making-cakephps-pagination-work-with-modelexpects/">a new CakePHP-related tutorial</a> to the PHP-Coding-Practices.com website today showing a method that gets the framework's pagination to cooperate with a Model's expects() method.
</p>
<blockquote>
Making CakePHP's pagination work together with <a href="http://bakery.cakephp.org/articles/view/an-improvement-to-unbindmodel-on-model-side">Mariano Iglesias'</a> expect functionality seems to be impossible. The expect()'ed associations are only used in the paginator's findCount() call, but not in the findAll() call which actually retrieves the results. Come on join me and find out how to fix this.
</blockquote>
<p>
His <a href="http://php-coding-practices.com/cakephp-specific/making-cakephps-pagination-work-with-modelexpects/">solution</a> involves the creation of a custom pagination method that ends up calling the Paginator helper with some special parameters (replacing the non-cooperative defaults).
</p>]]></description>
      <pubDate>Fri, 24 Aug 2007 07:55:00 -0500</pubDate>
    </item>
  </channel>
</rss>
