It's possible to change ID Generator on tests? #8840
-
In my functional tests i do something like "$request->get('product/a/1')" to get the detail from product "A = 1". The thing is that every time i make fixtures (FixtureBundle) for different products, ID's changes and the ID's on tests are hardcoded so i've to rewrite them all every time i create a new one. I've tried overwritting metadata generator type (NoneType and Custom) to hardcode the ID before persist, but this doesn't work, i think because inheritante mapping (joined). Any ideas? Edit: Using "AssignedGenerator()", doesn't work. Error: "number of bound variables does not match number of tokens". The ID field is not present in the SQL query. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@fernandofdzcode It might be possible by messing with the |
Beta Was this translation helpful? Give feedback.
@fernandofdzcode It might be possible by messing with the
ClassMetadata
if you find all the right properties and respect the inheritance hierachy, but this is not an official way and not really recommended. You could always introduce a custom ID Generator that wraps and instantiates different implementations based on Test or Production, that is my best guess on how to get it working.