<?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>Tue, 21 May 2013 03:38:33 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Simon Jodet: Partial mocks with Mockery]]></title>
      <guid>http://www.phpdeveloper.org/news/19036</guid>
      <link>http://www.phpdeveloper.org/news/19036</link>
      <description><![CDATA[<p>
<I>Simon Jodet</i> has a <a href="http://blog.jodet.com/posts/2013-01-14-partial-mocks-with-mockery.htm">new post to his site</a> for the Mockery users out there (a <a href="https://github.com/padraic/mockery">mocking tool</a> used in unit testing) showing how he created his partial object mocks.
</p>
<blockquote>
I really like atoum and highly recommend it. However, because it's a young project, I have two problems with it: The documentation was really lagging but it's getting there and integration with other tools is poor. [...] And then I stumbled on <a href="https://github.com/padraic/mockery">Mockery</a>. Unlike atoum, it doesn't replace PHPUnit, it just replaces its mocking system with a more elegant, powerful and reliable one. The big plus of Mockery over PHPUnit is that you don't need to have the class to mock to create a mock. [...] But writing partial mocks with Mockery is not obvious.
</blockquote>
<p>
He illustrates with a "Database" class example containing four methods, only three of which he wants to mock out - dropTable, listTables and getSchema. The fourth method, "reset", is then called directly and the mocked methods are used inside that. The database connection mock is then injected into the Database mock and the test is run. Complete code examples are provided.
</p>]]></description>
      <pubDate>Tue, 15 Jan 2013 09:10:14 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: Mockery: A Better Way]]></title>
      <guid>http://www.phpdeveloper.org/news/18790</guid>
      <link>http://www.phpdeveloper.org/news/18790</link>
      <description><![CDATA[<p>
On NetTuts.com there's a new tutorial posted showing you how to <a href="http://net.tutsplus.com/tutorials/php/mockery-a-better-way/">use Mockery in your unit testing</a> as an alternative to the built-in mocking tools of something like <a href="http://phpunit.de">PHPUnit</a>.
<p>
<blockquote>
<a href="https://github.com/padraic/mockery">Mockery</a> is a PHP extension that offers a superior mocking experience, particularly when compared to <a href="http://www.phpunit.de/manual/current/en/index.html">PHPUnit</a>. While PHPUnit's mocking framework is powerful, Mockery offers a more natural language with a Hamcrest-like set of matchers. In this article, I'll compare the two mocking frameworks and highlight the best features of Mockery.
</blockquote>
<p>
He walks you through the installation of Mockery and includes the code for a sample PHPUnit test that creates a Mockery instance and mocks out a class object for testing. He moves on to more examples including:
</p>
<ul>
<li>Adding expects for method calls (single and multiple)
<li>Returning values from the methods
<li>Calling multiple methods
<li>Returning different things based on parameters
<li>Partial mocks
<li>Handling constructor parameters
</ul>]]></description>
      <pubDate>Thu, 22 Nov 2012 12:06:02 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Emran Hasan's Blog: Using Mockery as a mocking framework with PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/17732</guid>
      <link>http://www.phpdeveloper.org/news/17732</link>
      <description><![CDATA[<p>
<i>Emran Hasan</i> has <a href="http://phpfour.com/blog/2012/03/using-mockery-as-a-mocking-framework-with-phpunit/">posted an introduction</a> to using the <a href="https://github.com/padraic/mockery">Mockery</a> mocking tool with <a href="http://phpunit.de">PHPUnit</a> for a more powerful, easier to use object mocking system.
</p>
<blockquote>
A few days ago I was explaining mocking to a few colleagues. I came up with the following quick n dirty code to show them the elegance of Mockery as a mocking framework. The code is straight-forward: it checks the health of a server using a tiny heart beat script.
</blockquote>
<p>
He provides both sides of the code - a simple "heartbeat" script that just responds with a JSON result, the class to consume it, a HTTP wrapper class that will be the target of the mock and his PHPUnit tests (testSystemIsOnlineWhenServiceRuns). You can see the use of the Mockery tool in this test.
</p>]]></description>
      <pubDate>Mon, 26 Mar 2012 14:52:03 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jakub Zalas' Blog: Mocking Symfony Container services in Behat scenarios with Mockery]]></title>
      <guid>http://www.phpdeveloper.org/news/17428</guid>
      <link>http://www.phpdeveloper.org/news/17428</link>
      <description><![CDATA[<p>
<i>Jakub Zalas</i> has <a href="http://www.zalas.eu/mocking-symfony-container-services-in-behat-scenarios-with-mockery">a recent post</a> to his blog with a hint about how to test Symfony container services by mocking them (when testing with <A href="http://behat.org/">Behat</a>) with the help of <a href="https://github.com/padraic/mockery">Mockery</a> (and the <a href="https://github.com/PolishSymfonyCommunity/PSSMockeryBundle">PSSMockeryBundle</a>).
</p>
<blockquote>
Mocking objects in unit tests is pretty straightforward as every object used in a test case is usually created in a scope of one test class. In functional tests it's a bit harder since we either don't have full control over objects being created or it's simply too laborious to mock half the framework. [...] We're getting the service from a container [in the example] and calling a method which should send a lead. The problem is we don't want to actually call an API while executing Behat scenarios.
</blockquote>
<p>
Rather than hitting up the API for each test, he opts to create mock objects and results with the tools <a href="https://github.com/padraic/mockery">Mockery</a> has to offer. He gives code for a "is API available" method that either returns a valid container or a mocked object, depending on how it was called.
</p>]]></description>
      <pubDate>Fri, 20 Jan 2012 13:54:52 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Wojciech Sznapka's Blog: Why Mockery is better than PHPUnit Mock Builder (with Symfony2)]]></title>
      <guid>http://www.phpdeveloper.org/news/17074</guid>
      <link>http://www.phpdeveloper.org/news/17074</link>
      <description><![CDATA[<p>
<i>Wojciech Sznapka</i> has a new post today sharing his opinions as to why <a href="http://blog.sznapka.pl/why-mockery-is-better-than-phpunit-mock-builder-and-how-to-integrate-it-with-symfony2">Mockery is better than PHPUnit Mock Builder</a> in testing Symfony2-based applications.
</p>
<blockquote>
Recently I did a lot of Test Driven Development on my Symfony2 bundle. I used PHPUnit's built-in <a href="http://www.phpunit.de/manual/3.5/en/test-doubles.html">mocks and stubs</a> for many projects, so I took it again. But while I was working on mocking Symfony2 core objects I found those mocks very uncomfortable in use. I tried <a href="http://blog.astrumfutura.com/2009/03/the-mockery-an-independent-mock-object-and-stub-framework-for-php5/">Mockery</a> and it saved my day. Let's see how to get it working with Symfony2 and how it kicks ass!
</blockquote>
<p>
He shows how to get things set up - adding Mockery to the dependencies file (deps), getting the latest version from their git repository and an example mock method that shows the difference in mocking the Doctrine2 entity manager - PHPUnit vs Mockery.
</p>]]></description>
      <pubDate>Wed, 02 Nov 2011 13:02:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: A Mockery Review]]></title>
      <guid>http://www.phpdeveloper.org/news/16315</guid>
      <link>http://www.phpdeveloper.org/news/16315</link>
      <description><![CDATA[<p>
On the Web Builder Zone (a part of <a href="http://dzone.com">DZone.com</a>) there's a recent post from <i>Giorgio Sironi</i> <a href="http://css.dzone.com/articles/mockery-review">reviewing the Mockery library</a>, a mock object framework created by <a href="http://blog.astrumfutura.com/">Padraic Brady</a>.
</p>
<blockquote>
<a href="https://github.com/padraic/mockery">Mockery</a> is a mock object framework (more properly Test Double framework) from <a href="http://twitter.com/padraicb">@padraicb</a>, independent from testing frameworks like PHPUnit. It can be used to quickly prepare Mocks, Stubs and other Test Doubles to use inside your unit tests. I've tried Mockery via a PEAR installation and I must say its expressive power is higher than that of PHPUnit mocking system. However, it may be too powerful for effective usage.
</blockquote>
<p>
He talks about some of the features that are in Mockery that aren't in <a href="http://phpunit.de">PHPUnit</a> like alternative expectations, recording of the expected calls and the mocking of non-existent methods. He notes that it can be too overwhelming at times, though, with so many features that may or may not be useful for the large majority of testers. He includes some sample code showing a set of five tests on a simple class implementing an interface.
</p>]]></description>
      <pubDate>Mon, 09 May 2011 13:05:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: The Mockery: An Independent Mock Object and Stub Framework for PHP5]]></title>
      <guid>http://www.phpdeveloper.org/news/12080</guid>
      <link>http://www.phpdeveloper.org/news/12080</link>
      <description><![CDATA[<p>
Noting the lack of a good, independent library for creating Mock Objects for unit testing PHP scripts, <i>Padraic Brady</i> (with assistance from <i>Travis Swicegood</i>) has come up with a standalone Mock Object and Stub framework - <a href="http://blog.astrumfutura.com/archives/392-The-Mockery-An-Independent-Mock-Object-and-Stub-Framework-for-PHP5.html">Mockery</a>.
</p>
<blockquote>
It's not tailored specifically to any one testing framework, rather it's an entirely separate framework with a discrete API. The idea is that you can use this framework within PHPUnit, or SimpleTest, or anything else really, without being forced to rely on the built-in support (if any) that test framework provides. Mockery was designed specifically to implement a form of Domain Specific Language (DSL). It makes extensive use of a fluent interface mixed with methods to approximate plain English.
</blockquote>
<p>
He includes an overview of what Mock Objects and Stubs are and how to set them up with the Mockery tool. He finishes things off with a look at the Mockery and Mock Object Expectation APIs. You can grab this first release either as a <a href="http://dev.phpspec.org/Mockery-0.1.0alpha.tgz">PEAR package</a> or from its <a href="http://github.com/padraic/mockery">github page</a>.
</p>]]></description>
      <pubDate>Fri, 06 Mar 2009 10:28:58 -0600</pubDate>
    </item>
  </channel>
</rss>
