PHP, Zend Framework and Other Crazy Stuff
Archive for December, 2007
Astrum Futura Redux
Dec 7th
For the cool folk who have followed the Solar Empire legacy through thick and thin since 1999, those cute .php3 file suffixes, Moriarty’s continuing denegration of all other developers, the revolution that open source brought, the sudden push towards OOP, and the…err…security and bug population… Working on anything hitting it’s 9th anniversary in PHP is really interesting – 9 times the fun and games
.
Astrum Futura was envisaged as a desperately needed update to the long running open source Solar Empire franchise, where players engage each other across a galaxy of 500+ star systems mining resources, building colonies, and generally screaming bloody murder at each other. It’s not the most impressive or ambitious of online games, but it’s always been tenacious and attracted roaming users who like a quick dash of destruction in their daily diet.
In January 2008, the oft delayed development process will once again creak into action. The current tracer code was built originally using the Zend Framework 0.2-0.6 and famously led that Spring to my long running “Complex Views With The Zend Framework” blog series that gave birth to the Zend_View Enhanced proposal, and maybe gave Ralph Schindler a few headaches
. Building anything more complex than a login page was pure heart ache previously.
Now that time is available, the Zend Framework significantly more mature, and we have a lot of legwork carried over from 2006 in the Quantum Game Library (thanks to Jacob Santos), it’s about time we got something concrete done. The usual suspects, if interest levels are high enough, can report to the shiny updated phpBB3 forums at http://forums.astrumfutura.com – same domain as this blog you’re reading.
And we will be applying XP this time – the random running process that usually prevails just doesn’t work out well. So get your Selenium gear in place.
PHPMutagen: Mutation Testing for PHP5
Dec 3rd
I swear – this is the last bdd/testing related idea I’m having for a long time
. There’s (so far) PHPSpec, PHPMock and now PHPMutagen. The first is a Behaviour-Driven Development framework, the other two are unrelated libraries intended for use with PHPSpec, SimpleTest, PHPUnit or any other conceivable testing framework.
As I said in my previous entry I was thinking about how to write a Mutation Testing engine. The “braindump” was to use PHP’s built in Tokenizer to break down a class file into digestable pieces which could be mutated, and then reconstructed into a mutated file. Once you allow for a working copy of the original source (let’s not mutate the original!) it turned out to be a reasonable approach.
The source code is still rough, but essentially operational. I wouldn’t get too excited until I find some time to scan through it again (after I get over this cold) and get the spec coverage into shape. For the moment I’ll tease you all with some sample output.
Here’s what you really want to see after running PHPMutagen (note this was only possible with PHPSpec, but a PHPUnit or PHPT adapter would be equally simple to add later):
.......
7 Mutants born out of the mutagenic slime!
7 Mutants exterminated!
No Mutants survived! Muahahahaha!
Here’s what you probably want not to see
. The comment at the end is important – in Mutation Testing there will always be a few elusive ghosts which aren’t a real problem because you can switch operators in code without altering behaviour in some circumstances. Using < or <= in a for loop for example.
….M..
7 Mutants born out of the mutagenic slime!
6 Mutants exterminated!
1 Mutant escaped; the integrity of your suite may be compromised by the following Mutants:
1)
Index: /opt/mutesting/src/PHPMock/Expectation.php
===================================================================
@@ -147,9 +147,9 @@
public function verifyCall(array $args)
{
$this->_validateOrder();
- $this->_actualCallCount++;
+ $this->_actualCallCount–;
if (!is_null($this->_exceptionToThrow)) {
if (is_array($this->_exceptionToThrow)) {
$class = $this->_exceptionToThrow[0];
$message = $this->_exceptionToThrow[1];
Happy Hunting! Remember that some Mutants may just be Ghosts (or if you want to be boring, false positives).
The diff output for a mutant is courtesy of PEAR::Text_Diff's unified diff renderer and a little extra decorating.
