You know that thing that happens when you love writing unit tests so much that you completely forget the argument order of all the
Yeah it does happen, I’m sure it is not just me
You write everything in as
$this->assertEquals( function_call(), 'expected string' ); and then you get really confused when phpunit tells you it expects the wrong result from the function you haven’t implemented yet and received the expected result.
Good, I managed to write tests the wrong way round for two days before I realised and I wasn’t looking forward to going through and correcting them all, but then I remembered the power of
sed and started cooking a recipe up.
It turned out pretty simple:
sed -i "s/\(.*assert[^(]*\)( \([^,]*\), \([^)]*\) );/\1( \3, \2 );/" file_of_tests.php.
What it does:
- Capture the start of the line up to the call to the assert function in ‘\1′
- Capture the two function arguments in ‘\2′ and ‘\3′
- Rewrite the matched line with the arguments switched
That was fun!
Had a great time today at the #horshamcoworking meetup with @LoudMouthMan and @CliveWalker. Looking forward to future events.
Last night I did a short presentation on Scaling WordPress using WordPress.com as an example giving an overview of the solutions we use for different scaling issues as well as highlighting some solutions that you can try out on smaller sites:
A recent discussion around the way we write and share small helper scripts inside Automattic made me think a lot about why I do things the way I do and why I am against “authorship attribution” in shared code.
The views I have are strong and I think a good guiding principle for working collaboratively with your peers especially in Open Source projects:
I am very strongly against authorship attribution – it puts up a barrier to contribution by setting a subconscious ownership barrier around things.
I give you my code to do as you wish, I mold your code to do as I wish, I blame early and often when searching for bugs, and I expect you to have forgotten you wrote the tool I’m asking you about especially if you committed it yesterday!
What is your ethos and what do you think of mine?