Fixing the Dubious Symfony Test Harness

Although Symfony’s original baked-in test framework, Lime, is being replaced by PHPUnit in Symfony 2, I figure I should post a fix for those, like me, who will be stuck for the foreseeable future in Symfony 1.x with an older suite of tests.

In general, Lime works pretty well except when running multiple tests in the harness. For example, when you run a specific test or tests:

$ ./symfony test-unit util
# isEmailValid()
ok 1 - returns an integer
ok 2 - is a valid email address
ok 3 - test@test is not a valid email address

Lime plays along nicely. But when you run all of your tests via the test harness like so:

$ ./symfony test-unit
Test returned status 1
Test returned status 1

the results can be dubious.

“Dubious” here means that the test crashed somehow during execution and so Lime doesn’t know if it would have passed or failed. To see what’s going on, pop open symfony/vendor/lime/lime.php. Depending on your version, you should see a block like the following inside lime_harness->run():

ob_start(array($this, 'process_test_output'));
passthru(sprintf('%s -d html_errors=off -d open_basedir= -q "%s" 2>&1', $this->php_cli, $file), $return);

Never mind that the above passthu may not work on Windows (see ticket #5437), if you comment-out the output buffering and run your tests again, you’re likely to discover that Symfony can’t autoload Symfony libraries, base classes, or what-have-you; for example:

$ ./symfony test-unit
Fatal error: Class 'sfCore' not found in D:\app\test\unit\happyTest.php on line 8
Call Stack:
0.0004 70248 1. {main}() D:\app\test\unit\happyTest.php:0

The easiest fix is to work around this whole executing tests via passthru nonsense. A good old “include”, like Pake does when you run one test at-a-time, will do just fine. Patch lime.php:

ob_start(array($this, 'process_test_output'));
$return = include($file);

Then add a “return 0;” to the end of each of your tests. (Yes, the Lime harness expects zero to indicate success..)

Now the harness should run just fine:

$ ./symfony test-unit
All tests successful.
Files=2, Tests=10

Of course, this will break the harness for the functional tests, but that’s a fix for another post.


As I alluded last December, things are starting to heat up.  Or maybe melt up. Either way, it’s time for a rant.

When I started looking into the whole Colonel-Klink-Says-All-Your-Bank-Belong-To-Us thing back in 2008, I don’t think I expected that I would ever get to a point where this stuff would make sense to me. And yet here we are, 2011, and a mere moment of WTF has blossomed into a daily obsession.  Gold, inflation, and unemployment are up. Way up.  The dollar is going down, possibly for the count.  So, in some very broad and potentially dyslexic brush strokes, here is my tinfoil hat outline of what I think got us here.

Our current version of the crises began back in 2007, just as the U.S. real estate market was beginning to dip.  This dip occurred after years of the dipshit Bush administration pushing for a so-called “ownership society,” essentially encouraging a fraudulent mortgage market, because, like, who in their right mind would believe that real estate could ever lose value? Right?  But really the whole ownership society nonsense was undertaken simply as a way to promote a housing bubble as well as to prop-up the feel-good illusion of wealth (along with Larry Summers’ career).  The housing bubble was originally inflated by Maestro Greenspan so that we wouldn’t have to feel the post-bubble hangover of the Dot Com years.  Aaand the slow motion Dot Com train wreck was the result of irrational exuberance generated by the sudden and untapped ability of entrepreneurs to sell, for example, designer pet condoms to anyone in the world day or night… all thanks to wonders introduced by Dr. Al Gore and his newfangled informational superhighway.

The problem with where we are now is that some quasi-corporate-governmental entities, by which I specifically mean Colonel Paulson and his goddamn pet vampire squid at America Inc., had invented a way to proffer “ownership” on the cheap, to anyone, no questions asked.  Sort of like the American Dream meets American Idol with only one judge, Paula Abdul, telling everyone they’re beautiful and, oh, by the way, here’s a freaking house.  Not surprisingly, people believed they were beautiful.  And they took the freaking houses.  And suddenly everyone was getting rich and unicorns were flying through the skies shooting adjustable rate rainbow happiness from their butts.

This is how the market came to be flooded with Frankensteinian credit default swaps:  Bad mortgages sliced, diced, mislabeled, and bandied around the financial world as prime chuck happy unicorn meat.

Anyway, back to 2007.  After almost a decade of real estate spiking at around 20% annual growth, suddenly the market begins to implode, rates go up, and many folks can’t repay their loans.  Soon it becomes apparent that the prime chuck was subprime after all.  Lehman Brothers fails.  And then Bear Stearns is about to go under.  And then the government steps in making a big fuss about AIG also being in trouble and the fact that, Holy Mother of God, global businesses need their insurance so we’ve got to make sure that AIG is stable and oh by the way JP Morgan is going to acquire Bear Stearns so don’t worry about that cause we fixed it ‘k thanks bai.

Fast forward to “The Year of Recovery” 2010.  Ben “The” Bernanke makes a number of somber appearances and talks about how he is 100% sure that he can “fix” the economy.  Most Americans, however, slowly become aware that the U.S. government is going to do it’s damnedest to simply print it’s way out of the mess.  The Obama administration obliges by pushing the deficit towards critical mass, in part by transferring a ridiculous amount of wealth to — what’s this? — the insurance industry.

At this point, one would think the American government had paid for enough insurance to protect us from catastrophic economic collapse.

But massive inflation is an elegant solution in it’s own sinister way:  If the U.S. can devalue it’s currency just enough… then it’s real debts become manageable, imports become expensive, Americans start consuming at home, a domestic recovery begins (well, maybe) and the rest of the world gets stiffed with a devalued reserve currency. If the U.S. can somehow hang on to reserve currency status during all of this, problem solved.

Or, maybe, problem transferred. Again. For now the real problem is that the US is not just upchucking greenbacks off in a corner of rural America somewhere; in reality it’s rampaging around projectile inflating all over the entire fricking world. Trillions of virtual Reserve dollars leaked into global commodities pushing up prices and edging entire nations into poverty.

Visit for breaking news, world news, and news about the economy

So by unleashing a tsunami of “credit,” the Fed is damning the world to guns for want of butter.

And why? Because the “Too Big To Fails” have already failed.

Big Five Failures
Five banks account for 95% of the unicorn meat. The same organizations that logged record bonuses in the wake of the TARP hold up.

Notice that guy at the front of the cart? JP Morgan. The one holding the biggest sack of sub prime. The one who quietly acquired Bear Stearns. It’s clear now that JP Morgan, and Bear Stearns before it, has been manipulating the price of precious metals for decades; in part, most likely, to prop up the dollar. If Bear Stearns were out-and-out allowed to fail, the jig could have been up in 2008.

But it wasn’t up, and in 2011 we’re still jigged. So for now, inflation, no matter the cost, to cover up decades of theft and corruption, to keep a failing debt-based global financial gravy train rolling, even off the rails, as long as possible, is the order of the day.

Someday, however, the system will fail. It will fail everywhere. What we’re seeing now is just the beginning.

Let’s just hope there’s enough unicorn to go around.

Appending fixtures via the propel-load-data task in Symfony 1.0.x

Not sure if this is a little more clear in later releases of Symfony, but in 1.0.x the load-data task, as outlined in the documentation and cookbook, is somewhat vague.

If you’re appending a fixture to an existing database, here’s what you want to do:

$ php symfony propel-load-data <APPLICATION_NAME> [<ENVIRONMENT_NAME>] <FIXTURES_DIR_OR_FILE> append

so usually I do something like this:

$ php symfony propel-load-data frontend data/fixtures/import_data.yml append

I’m actually not sure how ENVIRONMENT_NAME would come in to play.. Either this is a way to select per-environment fixture data (probably), or per-environment databases to which to apply the data.