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
Dependency managementNote 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 composerSo let's start by downloading composer from http://getcomposer.org/download/ and follow their instruction.
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
curl -s http://getcomposer.org/installer | php
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
which installs the development dependencies too. I like this composer stuff to get started.
php composer.phar install --dev
Running phpunitRunning 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 componentAs 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 fixtureBy 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.
so lets test this with Symfony by editing one of the tests fixtures.
msgid "User interface"
msgstr "Interfície d'usuari"
This will show two failures. So our unittests do some good work.
# remove all whitelines (this is just the last line) or just add some (depending on Symfony current state)
Installing phpunitInstalling 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