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?
git clone https://github.com/symfony/symfony.git
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.
So let's start by downloading composer from http://getcomposer.org/download/ and follow their instruction.
curl -s http://getcomposer.org/installer | 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 all tests is easy. (When you don't have phpunit see below for how I managed this on a Mac OS 10.6)
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.
What are those skipped tests?
phpunit --verbose src/Symfony/Component/Translation/
Changing a fixture
By downloading ie http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.11.nl.po we see these files have no whitelines between each translation item.
msgid "User interface"
msgstr "Interfície d'usuari"
so lets test this with Symfony by editing one of the tests fixtures.
# remove all whitelines (this is just the last line) or just add some (depending on Symfony current state)
This will show two failures. So our unittests do some good work.
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.phpunit.de
# pear channel-discover components.ez.no
# pear channel-discover pear.symfony-project.com
# pear install phpunit/PHPUnit
# pear upgrade
pear install --alldeps phpunit/PHPUnit