Archive

Archive for the ‘Symfony’ Category

Breaking down the insurmountable task of writing legacy tests in Symfony

November 3rd, 2009 admin No comments

If you’ve inherited an application written with the Symfony framework that doesn’t include functional tests (or you just plain didn’t write them to being with) it can seem like an insurmountable task to create any significant level of code coverage. I found myself in this position and felt overwhelmed by the task ahead of me.

Heeding the advice of my productivity guru: “don’t bite off more than you can chew” (thanks ma!), I used the following grep sequence to generate some organic milestones. Now I know the number of actions per module

grep -c "function execute[A-Z]" apps/frontend/ -R | grep ".php:" | grep -v ":0$" | grep -v "components.class.php"

Categories: Symfony Tags:

Prevent Symfony from ‘formatting’ request parameters

September 15th, 2009 admin No comments

I’ve been using Symfony for 2 years and I always though their formatting of routes was really cool. For example, if you want to generate a link to a specific action, you’d do something like this:

<?php
echo link_to('Name of Link', '@route_to_action?param1=value1&param2=value2');

And it would generate something like this:

<a href="/module/action/param1/value1/param2/value2">Name of Link</a>

However, for the first time, I found myself NOT wanting this behavior. I wanted:

<a href="/module/action?param1=value1&param2=value2">Name of Link</a>

I looked high and low, on and off for a few days. I finally found something in the forums, with a note saying it should be in the documentation, but isn’t.

<?php
echo link_to('Name of Link', '@route_to_action', array('query_string' => 'param1=value1&param2=value2');
64670 be
Categories: Symfony Tags: