Open FlorianLB opened 11 years ago
MMh, Ok. Why not, it's like an "helper" for this redundant task. Maybe we should go for an event based or a chained cleaner ? cause you can have multiple needs & if the goal is to re-use cleaner services, we could have many cleaner to call.
Hum, event based cleaners seems to be a good idea. I will do it today if i can.
@stephpy some comments about this ? Useful to include in the bundle ?
Hi, sorry for delay. That's a really good feature.
I'm not sure but a
function afterTestMethod {
kernel->shutdown();
}
can avoid some issues of connections which could stay opened, no ?
Then, we'll have in future to implements some clearer but how "client" will integrate it to application ? Since it is used via the eventDispatcher, we'll not be able to "activate/deactivate" a specific clearer. (I'm may be wrong)
What about a ClearerCollection which add clearers (via atoumBundle or custom) via tag
system. We'll have to use annotation like that:
@Clean('myClearer')
//or
@Clean('[doctrine, redis]')
It's only a proposal, i'm sorry for explain it 6 days after your first commit :s I can contribute to implement this idea if you like it and don't want to implement it yourself.
+1 for kernel shutdown.
The main goal of the event system is to define your own annotation based on Clean
that overload the name of the event that will be dispatch so u can have :
@ORMClean
@ODMClean
@RedisClean
And you can pass options to the annotations to have a better granularity.
I think it offers an highly customizable mechanism, no ?
Yes, it is, that's a good idea (i did not understand it), forget my purpose, your solution is the best !
It appears ok. Could you ship some documentation ? I have to rethink about the use case/context twice.
I can look for implementing ORMClean
and RedisClean
once this PR is merged, thanks for this work.
I will try to add some docs this weekend.
Few months ago we talked with @stephpy about a cleaning (db drop/create, load fixtures, etc) mechanism based on annotations on test method.
This is my implementation. There is only the base classes, users must implements their own cleaner and annotations (in the future we could provide generic annotations/cleaners).
Need your feedback about it :)