I just did it for silex , which is a micro structure based on Symfony2. From what I understand, this is very similar. I would recommend it as a primer for Symfony2-world.
I also used TDD to create this application, so I did this:
testcase ( tests/ExampleTestCase.php) :
<?php
use Silex\WebTestCase;
use Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage;
class ExampleTestCase extends WebTestCase
{
public function createApplication()
{
return require __DIR__ . '/../bootstrap.php';
}
public function setUp()
{
parent::setUp();
$this->app['session.storage'] = $this->app->share(function () {
return new ArraySessionStorage();
});
}
public function testHome()
{
$client = $this->createClient();
$crawler = $client->request('GET', '/');
$this->assertTrue($client->getResponse()->isOk());
}
}
my bootstrap.php:
<?php
require_once __DIR__ . '/vendor/silex.phar';
$app = new Silex\Application();
$app->register(new Silex\Extension\SessionExtension());
$app->get('/home', function() use ($app) {
return "Hello World";
});
return $app;
web/index.php:
<?php
$app = require './../bootstrap.php';
$app->run();