A port of the Symfony2 testing mechanism to symfony 1.X.

dev-master 2012-02-01 18:10 UTC


A small library that brings the Symfony2 functional testing mechanism into symfony 1.X.


Clone the repository under the lib/vendor/odino directory: you can change the location of the library, although this is the recommended one.

git clone git@github.com:odino/SfCcTesting.git lib/vendor/odino/SfCcTesting

Move into the library's root, download composer and install the dependencies:

cd lib/vendor/odino/SfCcTesting
wget http://getcomposer.org/composer.phar
php composer.phar install

Make a symbolic link from the root of your application to the default phpunit.xml.dist configuration file:

ln -s lib/vendor/odino/SfCcTesting/phpunit.xml.dist phpunit.xml

(this is just a hint, you can use your specific configuration file)

Write your first test:

touch test/phpunit/HomepageTest.php

use Symfony\Component\DomCrawler\Crawler;
use odino\SfCcTesting\WebTestCase;

class HomepageTest extends WebTestCase
  public function testHelloWorld()
    $client = $this->createClient();
    $crawler = $client->get('/');
    $this->assertEquals("Hello world", $crawler->filter('h1')->text());
  protected function getApplication()
    return 'frontend';
  protected function bootstrapSymfony($app)

and run it with a simple phpunit test/phpunit from the root of your symfony 1.X project.

testing output#