There are 6 articles tagged as "mockery"

Easier Mocking With Mockery in php[architect]

on April 20, 2018. in Blablabla. A 1 minute read.

In early February I got an email from Oscar would I be willing to write an article for php[architect], based on my “Easier mocking with Mockery” talk. It took me maybe 2 seconds to think about it and say “Yes!”. The first part of the article was published in the April’s edition of the magazine. Lots of useful content in there, not just my article!

Mockery partial mocks

on January 28, 2018. in Programming, Development. A 3 minute read.

In dealing with legacy code I often come across some class that extends a big base abstract class, and the methods of that class call methods on that big base abstract class that do an awful lot of things. I myself have written such classes and methods in the past. Live and learn.

Continue reading Mockery partial mocks...

Mockery return values based on arguments

on December 12, 2017. in Programming, Software, Development. A 3 minute read.

Sometimes when working with Mockery mock objects, we want to tell a mocked method to return different values for different arguments. It is a rare occasion when I need this feature, but every time I need it, I’m happy it’s there.

Complex argument matching in Mockery

on May 08, 2017. in Programming, Software, Development. A 3 minute read.

This past weekend I did some issue maintenance and bug triage on Mockery. One thing I noticed going through all these issues, is that people were surprised when learning about the \Mockery::on() argument matcher. I know Mockery’s documentation isn’t the best documentation out there, but this still is a documented feature.

Mocking hard dependencies with Mockery

on December 23, 2014. in Development, Programming. A 2 minute read.

One problem with unit testing legacy applications is that the code has new statements all over the place, instantiating new objects in a way that doesn’t really makes it easier to test the code.

Unit testing Zend Framework 2 modules

on September 15, 2012. in Development, Programming, Software. A 5 minute read.

Porting this blog to Zend Framework 2, I decided to write some unit tests as well, while I’m at it. Not that the current code base doesn’t have unit tests, just it doesn’t have much of it… Anyway, I’d like to show how to get unit tests for modules up and running, as well how to throw in Mockery in the mix, as it can help us greatly with mocking out objects. Some of the parts shown here probably could be written in a more cleaner/nicer way, especially the autoloading bit, but so far it works for me.