I have a Zend Framework application (version 1.11) that uses Doctrine 2. I\'ve got PHPUnit set up to run tests on my models and forms and whatnot. The tests work great, but
1. Regarding "cleaning up":
Because you are using InnoDB you can use transactions to restore the DB to the same state as it was before the test started:
So in setUp()
you would add $this->em->getConnection()->beginTransaction();
and in tearDown()
$this->em->getConnection()->rollback();
This restores the database to the previous state. Also have a look at MySQL handbook on "The InnoDB Transaction Model and Locking" to make sure that this does not interfere with any other data in your application (keyword: isolation level).
2. Regarding rolling back auto increment ids:
As far as I know this is not (easily) possible. There is a thread about it on SO in which it is stated that your application should not care if there are gaps between the auto increment ids. If you are using a test database (which is highly recommended) this should be even a lesser concern.