Symfony development from a Drupal perspective

While still working on D8MI Let Symfony Translation component handle language messages I needed to code for Symfony to on the Translation component. So how does that work writing and testing Symfony code?

Download Symfony

cd /tmp
git clone 
cd symfony

Dependency management

Note the composer.json which is key to get the Symfony phpunit test running. As a Drupal developer new thing are to be learned. Composer manages all dependencies needed to run either a Symfony application or the phpunit test. As we are developing for Drupal but need to be able to convert Drupal Gettext related test cases to Symfony we need to be able to run Symfony unit tests.

Awesome composer

So let's start by downloading composer from and follow their instruction.
cd /tmp/symfony
curl -s | php
This installs a composer.phar file which is capable to process the composer.json and download all dependencies needed to run the phpunit tests. You can run
php composer.phar install
to see all runtime dependencies being downloaded and installed. As a Symfony developer you need the development dependencies too. Install these through composer.
php composer.phar install --dev
which installs the development dependencies too. I like this composer stuff to get started.

Running phpunit

Running all tests is easy. (When you don't have phpunit see below for how I managed this on a Mac OS 10.6)
cd /tmp/symfony
and see all tests running smoothly. Note the S's which are skipped unit tests.

Run the Translation component

As this blog is about D8MI we need to run the Translation tests.
cd /tmp/symfony
phpunit src/Symfony/Component/Translation/

What are those skipped tests?

cd /tmp/symfony
phpunit --verbose src/Symfony/Component/Translation/

Changing a fixture

By downloading ie we see these files have no whitelines between each translation item.
msgid "Home"
msgstr "Inici"
msgid "User interface"
msgstr "InterfĂ­cie d'usuari"
so lets test this with Symfony by editing one of the tests fixtures.
cd /tmp/symfony
vi src/Symfony/Component/Translation/Tests/fixtures/resources.po
# remove all whitelines (this is just the last line) or just add some (depending on Symfony current state)
phpunit src/Symfony/Component/Translation/
This will show two failures. So our unittests do some good work.

Installing phpunit

Installing phpunit (on Mac Os 10.6) This is from a lame history so I commented out some command.
sudo su -
pear channel-discover
# pear channel-discover
# pear channel-discover
# pear install phpunit/PHPUnit
# pear upgrade
pear install --alldeps phpunit/PHPUnit