I am using Symfony2 with Doctrine and I'm using the Alice Fixture bundle to generate my fixtures for testing.
In one case I need to create a fixture where the id is 148 for a specific test. All of our ids are configured to auto_increment, so I am currently creating 147 dummy records just to create the one I need.
I was hoping to use this definition to force the id to be set to 148:
invoiceClassNoClass (extends invoiceClass):
id: 148
sortOrder: 1
label: 'No Class'
Unfortunately this does not work. From a google search I read a brief comment stating that I first need to add a setId method to my entity. I tried that but it did not make a difference. In reality I do not want to add as setId method if I do not need to, as it violates our integrity rules where we never allow the setting of an id.
Perhaps there is reflection class that could be used? Perhaps this is built into Alice and I do not know about it?
If you want doctrine to save a certain value for an auto increment Id, then you have to deactivate auto increment in doctrine metadata. See
Explicitly set Id with Doctrine when using "AUTO" strategy