There are 9 articles tagged as "testing"

From time to time I come across a mistake in unit tests that makes them useless. The mistake is that we use the class and method that we are testing to create the expected result of the test:

Accessing Symfony private services in Behat

on February 01, 2019. in Programming, Development. A 2 minute read.

Since Symfony 3.4 the services in the service container are private by default. While this decision made us write better production code by making us use Dependency Injection more and rely on the service container less, using these services in a test environment proved to be a challenge.

Testing Symfony commands with Behat

on January 18, 2019. in Programming, Development. A 5 minute read.

The other day I was creating a Symfony command that will be periodically executed by a cronjob. I decided to write a Behat test for it, to see what a test like that would look like. Plus, just because it is executed by the system from a command line, doesn’t mean we can skimp on the business requirements.

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.

PHP traits to create test doubles

on April 04, 2017. in Programming, Development. A 3 minute read.

Keeping your application or library code well organized, easy to follow, and read is important. Your test code should not be exempt from those rules, you should follow good testing conventions.

Continue reading PHP traits to create test doubles...

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.

Frontend testing with phantomjs and casperjs

on January 29, 2013. in Development, Programming. A 7 minute read.

I am not usually fond of doing much frontend stuff, but I do like to dable in some javascript from time to time. Nothing fancy, no node.js, coffeescript and the likes for me. I still feel like making applications on the server side, and have the client just show things to the user. If needed some 3rd party javascript library or framework to make my life easier, and that’s about it.

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.