Over on his blog “Dev Blog”, Tom Oram has posted an informative new tutorial titled “Unit testing a Zend Framework 2 Controller“.
So far I’ve got a basic Zend Framework 2 Application up and running and got PHPUnit running & testing one of my models. Next up I wanted to try and workout how to test a controller.
I had come to the conclusion that what I needed to do was create an instance of my controller in an environment where it I could get it to run each action I wanted to test. I started stepping through the code and worked out that the MVC Application “dispatches” the controller which works out from the Router & Request which action it should run which it “execute” via an MvcEvent.
If you like blog posts with lots of code to cut-n-paste into your own files and play with, you are going to love this post. Tom gives you not only why he’s doing things but how he’s doing it so that you can repeat his success on your own.
Testing is important, we get that. It’s great though when trail blazers like Tom Oram stop and take the time to show us exactly how to get started. “Give a developer a fish…”
Read more : Unit testing a Zend Framework 2 Controller
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.