【发布时间】:2014-08-28 17:05:12
【问题描述】:
我尝试了各种方法,包括按照本文Setting headers for CakePHP Controller unit tests 的建议设置标头,但我似乎无法在控制器单元测试中模拟 ajax 请求。
我有这种情况
if ($this->request->is('ajax')) {
还有这个
if ($this->params['isAjax'] == 1) {
但条件不满足。,我什至尝试设置数组值$this->params['isAjax'] = 1;但出现错误
Indirect modification of overloaded property RoomController::$params has no effect
我的问题是如何在 cakePHP 中对控制器进行单元测试时成功模拟 ajax 请求。
【问题讨论】:
标签: php ajax unit-testing cakephp