2008年10月2日星期四

Re: [fw-mvc] How to test action controller method that communicates with external resources.

Oh... I see...

I supposes you can move the two methods from the controller to the service as static ones and obtain it using those methods.

I'm out of ideas...

Regards

2008/10/2 Piotr Czachur <zimnyx@gmail.com>
Emil,

Thanks for fast reply.

2008/10/2 Емил Иванов / Emil Ivanov <emil.vladev@gmail.com>:
> Hi Piotr,
>
> You can inject it in your controller:
>
> class ServiceController extends Zend_Controller_Action
> {
> protected $_service;
> public function setService($service)
> {
> $this->_service = $service;
> }
>
> public function getService()
> {
> return $this->_service;
> }
> }
>
> Use the setter to replace the service object and always obtain the service
> in your controller using the getter.

Controller object is created inside
Zend_Controller_Dispatcher_Standard::dispatch() method, so... in which
place do you want to call ->setService() ?
My whole post was rather how can I reach this controller during
dispatch(), and inject mocked object $service into it, not about
setters/getters and mock. Sorry if I wasn't clear.



Cheers,
Piotr Czachur



--
My place to share my ideas:
http://vladev.blogspot.com
http://carutoo.com

没有评论: