On 26.09.2010, at 23:59, Nicolas A. Bérard-Nault wrote:

> Hi all,
> 
> I am currently writing functional tests for one of my controllers which 
> queries the database. My strategy is to use sqlite:memory and export my 
> schema to the database using Doctrine 2's exporter, and then fill the 
> pseudo-database with random data.
> 
> First, I create the client and use its container to retrieve the Entity 
> Manager. I then export the schema and subsequently run my query. 
> Unfortunately, my fixture disappears because the 
> Symfony\Bundle\FrameworkBundle\Client class' doRequest() method reboots the 
> kernel, effectively nulling the container and creating a new one, which in 
> turn destroys my entity manager and creates another one, which, you've 
> guessed, resets the sqlite:memory database. Unless someone has a better idea 
> on how to inject the fixture data in my controller (remember I'm doing 
> blackbox testing), I would suggest moving the reboot() call after the request 
> is sent, which would make it possible to inject test fixtures into the 
> controllers.


I am looking at an alternative approach. The idea is to set the DIC to call a 
beginTransaction() when the EM is created when doing functional tests. This way 
you can essentially just load the fixtures once for all functional tests. I 
also added SAVEPOINT emulation for the Doctrine2 DBAL, this should allow to 
test even cases that rely on a rollback.

The main limitation, but this is also true for your case, is that you cannot 
properly test the output of subsequent pages. In our case we will be using 
PostgreSQL. I was thinking of maybe just configuring pgpool to just allow a 
single connection and check if I can tell PostgreSQL/PHP to not automatically 
rollback open connections at the end of a PHP request. In that case the 
uncommitted changes should stick around for another request and I would then do 
the rollback on the connection in the tearDown() method.

regards,
Lukas Kahwe Smith
[email protected]



-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to