·

photo credit: r.g-s A big regexp via photopin (license)

Regexes for quickly mocking stuff

Tags: ,

This is a small collection of regular expressions to find pieces of code and replace them with PHPUnit mocks. It’s useful for copy/pasting existing pieces of code (a constructor signature for example) and transforming them into usefull code for mocking in PHPUnit, without having to type everything out.

Disclaimer: some small code formatting might be required afterwards, but hey it’s better than nothing …

Declare your parameters

Regex:

Example text input:

Output:

Create Mock Objects

Regex:

Example text input:

Output:

How would you rate this article?

Leave a Reply