Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

/Dev/Hell Podcast:
Episode 86: Necromantic Spies and Imagined Corporate Friends
Jan 11, 2017 @ 15:28:44

The /Dev/Hell podcast, hosted by Chris Hartjes and Ed Finkler, has posted their latest episode today - Episode #86: Necromantic Spies and Imagined Corporate Friends:

Welcome to the very first episode of 2017! We’re back after a nice break for the holidays and ready to get back to being insightful and unfiltered. In this episode we talked about the concept of “programming as craft” with Chris and Ed having a great discussion about what should follow after the phrase “programmers need to learn empathy.”

Ed also released some music, and is donating all the proceeds to OSMI. Chris was sad that he did not get the opportunity to re-record the vocal tracks from some of Ed’s older material in his own signature vocal style. Chris also talked (not so briefly) about the new laptop he bought and the security measures he decided to take with it.

You can listen to this latest episode either using the in-page player or by downloading the mp3 directly. If you enjoy the show be sure to subscribe to their feed and follow them on Twitter for updates on when new shows are released.

tagged: devhell podcast ep86 spies friends chrishartjes edfinkler

Link: http://devhell.info/post/2017-01-10/necromantic-spies-and-imagined-corporate-friends/

Dave Marshall:
Mockery Spies
Oct 09, 2014 @ 15:29:08

In his latest post Dave Marshall takes a look at a handy feature of the Mockery mocking tool (helpful for unit testing) and how to use them in your testing.

Spies have been on the cards for mockery for a long time and even after putting together an implementation in February, I kind of stalled out on making a decision on the public API. Fast forward a few months and I figured it was just time to ship it, so I went with the most mockery like API and merged it in. Mockery still doesn't have a 1.0 release, so I can always make changes before we go 1.0.

For those not familiar with the concept of "spies" in testing he includes a brief definition and some of the reasoning behind using them. The first is relatively simple: how they can reveal the intent of the test. They also allow for two other types of testing methods, "Arrange-Act-Assert" or "Given-When-Then" thinking patterns. He does mention, however, some of the problems with using spies over mocks (including that they're less precise, possibly leading to looser testing). He finishes up the post with a quick note about partial spies and how they can provide a nice compromise in your testing.

tagged: mockery unittest spies doubles mock compare feature

Link: http://davedevelopment.co.uk/2014/10/09/mockery-spies.html

Chris Hartjes:
Test Spies and Mockery
Dec 31, 2013 @ 15:39:30

Chris Hartjes has a new post today looking at using test spies with Mockery, the alternative mocking framework to PHPUnit's own built-in functionality. Test spies are a feature that allows you to replace certain functions and methods of already created objects to help make mocking functionality easier.

While recording some screencasts I was struggling to figure out how to get PHPUnit’s built-in object mocking tools to allow me to create what is known as a “test spy”. I talk about them briefly in my PHPUnit Cookbook but I think that what I wanted to do in this instance was beyond what PHPUnit could give me.

He works through what he tried with the built-in PHPUnit mocking and found that it wasn't using the objects he provided as expected. He shifted over to Mockery and created a working version using the "shouldReceive" and "with" methods to handle the checks (spies) on the objects correctly.

tagged: unittest spies phpunit mockery example

Link: http://www.littlehart.net/atthekeyboard/2013/12/27/test-spies-and-mockery

DZone.com:
PHPUnit vs. Phake cheatsheet
Apr 19, 2013 @ 14:53:45

On DZone.com today Giorgio Sironi has posted a "cheat sheet" to help you correlate the functionality of two PHP unit testing tools - PHPUnit vs Phake (for mocking objects).

Benjamin Eberlei introduced me to Phake with his recent article: it is a Composer-ready PHP library that integrates easily with PHPUnit and provides an independent Test Doubles framework, capable of producing Stubs, Mocks, and Spies. The syntax and object model reminds me of Mockito, the Java Test Double framework from the authors of Growing Object-Oriented Software. I like tools that do one thing and do it well, and after experimenting with Phake I'm using it on all new code.

He compares the two tools on a few different pieces of functionality including creating stubs, mocks and spies. Sample code is included for both sides. It's not a detailed guide by any means, but it can give you a better picture of how the two compare.

tagged: phpunit phake mock stub unittest spies compare cheetsheet

Link: http://css.dzone.com/articles/phpunit-vs-phake-cheatsheet


Trending Topics: