Zend_Rest_Controller单元测试的示例 [英] Examples on Zend_Rest_Controller Unit Testing

查看:88
本文介绍了Zend_Rest_Controller单元测试的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了很多如何对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!

推荐答案

因此,基本上,您的问题是如何在控制器测试中模拟调用PUTDELETE? 由于这显然行不通:

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');

在此处详细了解如何处理RESTful路由-

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆