fideloper / Implementing-Laravel

Companion application to the e-book Implementing Laravel
173 stars 40 forks source link

Test controller that use form processing #29

Closed ronypur closed 9 years ago

ronypur commented 9 years ago

Is there any working example of testing on controller that use form processing as written in the book? I'm little confuse about how exactly to test controller with pattern like that. Is it necessary to test each method in the controller or is it enough just to test the the form processing class as a unit?

fideloper commented 9 years ago

I avoid testing controllers (having any http mechanism in tests) using this style of coding -- I just test the use cases/form classes.

You're question "is it necessary to test each method" - there's no strict or necessary way to do anything!

It should be noted, I haven't updated the book on this, but I'm now using Command Buses a lot - they are a bit more refined way of doing the same thing. Laravel 5 will have them baked in.

On Sun Jan 04 2015 at 9:04:15 PM ronypur notifications@github.com wrote:

Is there any working example of testing on controller that use form processing as written in the book? I'm little confuse about how exactly to test controller with pattern like that. Is it necessary to test each method in the controller or is it enough just to test the the form processing class as a unit?

— Reply to this email directly or view it on GitHub https://github.com/fideloper/Implementing-Laravel/issues/29.

ronypur commented 9 years ago

Thank you Chris, it's a lot more clearer now.