I\'m working on tests for a Symfony2 project, and right now I\'m looking for a way to create tests involving entity objects without persisting them. The problem is: id
You can configure doctrine to use an in-memory database in your app/config/config_test.yml
.
# app/config/config_test
doctrine:
dbal:
driver: pdo_sqlite
path: :memory:
memory: true
This speeds up the process and you can quickly persist some fixtures in the setUp()
method that will have (auto-generated) id's after flushing... all without messing with your "real" database.
You can find some inspiration in this answer and this blog post.