Using Prophecy with PHPUnit

We’ve recently been converting all of our PHP unit tests from SimpleTest to PHPUnit. For test doubles/mocks/spies/dummies, we’ve switched to exclusively using Everzet’s outstanding new mocking/stubbing library Prophecy, which PHPUnit 4.5 natively supports.

Prophecy is crazy cool, but you can definitely tell it was written for the magical BDD style that phpspec uses. Using it from within PHPUnit with non-BDD style semantics is a bit awkard and verbose. You have to write a bunch of lines of code just to spin up a quick and dirty test dummy. Say I just want an object that will return `false` for a certain method:

That’s a lot of typing with some weird semantics just to get a simple double.

Also, I found it really difficult to figure out some of the argument matching and spying features of Prophecy. The documentation is OK, but pretty sparse. I could tell that just about everything I wanted to do, I was pretty sure that Prophecy could do, but from reading the README and perusing the source code, I was still having a lot of trouble getting it do what I wanted it to do.

To mitigate these issues, I built a wrapper for using Prophecy within PHPUnit that gives you a terse but expressive layer of syntatic sugar on top of Prophecy called Ezekiel. It also adds simple, well-documented support for most of the basic mocking and stubbing use-cases you’ll encounter in an average test case. It also adds some cool convenience methods and tricks that make mocking/stubbing simpler and faster.

With Ezekiel, you can re-write the example above as:

Or stub simple returns for multiple methods like this:

Ezekiel has a longer syntax that allows you to match arguments and return different values based on arguments matched.

There’s a bunch more it can do as well, including returning the stub object, creating predictions, inspecting invocations, returning arguments by index, returning public properties of the test case. If you’re interested, it’s worth reading the full documentation, which is in the README file on GitHub:


It’s definitely simplistic and a bit naive, but that’s the point — it’s not meant to prevent you from ever using prophecy directly, just to give you a shorthand for common scenarios. The readme linked above has installation instructions if you want to give it a spin, or submit an issue or pull request.

ProPhoto, Mobile Layout, and Google SEO

By now, you may have heard that Google announced they plan to expand mobile-friendliness as a ranking factor this April – specifically, that sites which are mobile-friendly may rank more highly when someone searches Google using a mobile device. They’ll also be labeling sites which are mobile-friendly.

"mobile-friendly" appears next to search results

“mobile-friendly” appears next to search results, but only for mobile search

The idea is pretty sensible: when you’re using your phone to search on Google, you would prefer that sites you find are easy to use on your phone. Seriously, who likes zooming in/out to navigate & view a web page on their phone? This is 2015 for goodness sake!

Sites which look and work well on phones should begin to bubble to the top of search results on phones in the future. This might leave you thinking:

OMG, what is this going to mean for my ranking?!!1!!

The good news is we’re way ahead of you on this. We introduced a mobile-friendly layout option way back in 2011. ProPhoto 4 and 5 both make Google happy when you use the mobile layout feature and you can confirm that your site is mobile-friendly by pasting your site’s URL address into Google’s Mobile-Friendly Test tool, like you see in this example test of a ProPhoto demo setup:

ProPhoto sites using the mobile layout feature should pass Google's test

ProPhoto sites using the mobile layout feature should pass Google’s test

What if my site isn’t passing this test?

ProPhoto 4 and 5 pass this test by default, so if your site doesn’t pass for some reason, you might check to make sure ProPhoto is using the mobile layout option. Just login to WordPress and go to this area to check:
“ProPhoto” > “Customize” > “Mobile” > “General”
You can turn it on if it’s not enabled.

Mobile layout can be turned on/off in ProPhoto

Mobile layout can be turned on/off in ProPhoto

If you’re turning it on for the first time, you’ll want to also customize the settings applied to your special mobile layout. The mobile footer menu appearing at the bottom of your site should be checked, since it is separate from the menu you’ve setup for desktop visitors.

If your site still doesn’t pass the test with ProPhoto’s mobile layout turned on, try disabling WordPress plugins one-by-one and re-test, since some plugins might cause trouble. If things still aren’t working out, you can always contact us for guidance.

So, what about ‘responsive’ layout?

Pundits are throwing around the term responsive a lot lately, and many are suggesting that you need a responsive site layout for this upcoming Google change. But the truth is that a site doesn’t need to use responsive layout to be considered mobile-friendly. Thousands of ProPhoto users who have great search ranking can back this up, and so can millions of other websites which rank well without responsive layout, including our own. ProPhoto optimizes your site layout for tablets and phones without using responsive layout, and your visitors will be able to view and navigate with ease on mobile devices.

But rest assured, our developers realize that great site design can include responsive layout, too – that’s why they are working hard to bring responsive features to ProPhoto later this year. We’re excited to tell you more, so stay tuned to our blog and social media pages, and you’ll get the latest info on this front as we’re able to talk more about it.

Want to learn more about SEO, search ranking, and all of that? We have an SEO FAQ page you might find interesting.

Edit: …and if you’ve not seen it yet, we strongly recommend you check out the tutorial about customizing your ProPhoto Mobile Layout settings:

[link_list intro=”] [link slug=’mobile-site-overview’ title=” excerpt=”] [/link_list]

New P5 Feature: Infinite scrolling grids

We’re making ProPhoto 5 build #327 available today, which brings “infinite scrolling” functionality to grid excerpts.


A while back we added “infinite scrolling” and “load more posts” functionality to ProPhoto, which uses ajax to continually add more posts to your archive pages as visitors scrolled down the page or clicked the load more posts button.  This feature makes your content quickly accessible for visitors and gives your site a modern, dynamic feel.  Today, we’re extending this functionality to be compatible with ProPhoto grid excerpts as well.

If you’d like to use this feature, go to “ProPhoto” > “Customize” > “Site Settings” > “Misc.” > “ProPhoto Updates” and make sure your ProPhoto site is updated to build #327.  Then, if you are using a grid for your post excerpts (“ProPhoto” > “Customize” > “Content Appearance” > “Excerpts”), you can turn on dynamic grid loading by going to “ProPhoto” > “Customize” > “Content Appearance” > “Post Footer” > “Post navigation method” and selecting the “load more posts button” or “infinite scrolling option”.  Then you can go back to “ProPhoto” > “Customize” > “Content Appearance” > “Excerpts” > “Grid-style post display options” and you will see a new “animation style” option.


New grid items are added to the grid using the animation method selected here.  Their names are descriptive, but play around with them to see which one suits you best.

Follow us for the latest:

@pro.photo latest tweet:

Get a $30 rebate when you choose our recommended host, Bluehost