Zend_Rest_Controller单元测试的示例 [英] Examples on Zend_Rest_Controller Unit Testing
问题描述
我已经找到了很多如何对Zend_Controller进行单元测试的示例,但是我正在寻找有关Zend_Rest_Controller单元测试的示例.任何帮助,我们真的很感激.谢谢!
I have found a bunch of examples how to unit test Zend_Controller, but I'm looking for examples on Zend_Rest_Controller Unit Testing. Any help is really appreciated. Thank you!
推荐答案
因此,基本上,您的问题是如何在控制器测试中模拟调用PUT
和DELETE
?
由于这显然行不通:
So, basically your question is how to emulate calling PUT
and DELETE
in your controller tests?
Since this apparently doesn't work:
$this->request->setMethod('PUT');
通过提供_method
参数,您可以使用普通HTTP POST
访问这两种操作.
You can access both these actions with plain HTTP POST
by providing _method
parameter.
因此要致电PUT
:
$this->request->setMethod('POST');
$this->dispatch('articles/123?_method=put');
呼叫DELETE
:
$this->request->setMethod('POST');
$this->dispatch('articles/123?_method=delete');
More reading on how to deal with RESTful routing here - http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.rest
这篇关于Zend_Rest_Controller单元测试的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!