You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As already discussed in #8, only within a ModelLayer class it is possible to start and commit/rollback transactions, as for instance per definition Model methods should be atomic.
Now talking about PHPUnit, I would like to start in my setUp routine a transaction which will be rollbacked after a test completes to ensure data consistency among all tests.
What is the best way to achieve this? Or should I do something like:
I am using begin / rollback in tests in the way you described. But as my ModelLayer classes, which I want to test, use transactions itself, I need the ability that transactions can be nested through the use of savepoints. I achieve this through this trait, which overwrites the default transaction methods in ModelLayer.
But I am also interested in how others doing this. @chanmix51 said using transactions in tests is not a good idea. Instead one should use a separate schema for the tests and drop it afterwards. But since the schema is fixed in RowStructure::setRelation() by the cli model generator, how could this be circumvented?
As already discussed in #8, only within a ModelLayer class it is possible to start and commit/rollback transactions, as for instance per definition Model methods should be atomic.
Now talking about PHPUnit, I would like to start in my setUp routine a transaction which will be rollbacked after a test completes to ensure data consistency among all tests.
What is the best way to achieve this? Or should I do something like:
I am using Silex by the way ...
Cheers
The text was updated successfully, but these errors were encountered: