Skip to content

Conversation

@FlorianLB
Copy link
Member

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 :)

@ludofleury
Copy link
Contributor

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.

@FlorianLB
Copy link
Member Author

Hum, event based cleaners seems to be a good idea. I will do it today if i can.

@FlorianLB
Copy link
Member Author

@stephpy some comments about this ? Useful to include in the bundle ?

@stephpy
Copy link
Member

stephpy commented Apr 3, 2013

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.

@FlorianLB
Copy link
Member Author

+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 ?

@stephpy
Copy link
Member

stephpy commented Apr 3, 2013

Yes, it is, that's a good idea (i did not understand it), forget my purpose, your solution is the best !

@ludofleury
Copy link
Contributor

It appears ok.
Could you ship some documentation ? I have to rethink about the use case/context twice.

@stephpy
Copy link
Member

stephpy commented Apr 11, 2013

I can look for implementing ORMClean and RedisClean once this PR is merged, thanks for this work.

@FlorianLB
Copy link
Member Author

I will try to add some docs this weekend.

@jubianchi jubianchi modified the milestone: 1.2 Nov 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants