【问题标题】:'Cake\View\Exception\MissingTemplateException' with phpunit'Cake\View\Exception\MissingTemplateException' 与 phpunit
【发布时间】:2015-09-28 06:28:06
【问题描述】:

当我使用 Postman 等应用程序测试我的 REST API 时,它运行良好。

但是当我运行 phpunit 时出现错误

exception 'Cake\View\Exception\MissingTemplateException' with message 'Template file "Addresses/json/add.ctp" is missing.'

在 AppController 中

$this->RequestHandler->renderAs($this, 'json');

路线

$routes->extensions(['json']);
$routes->resources('Addresses');

ControllerTest 简单

$this->post('/addresses/');

因为它是 100% API,所以我不需要任何视图。

【问题讨论】:

  • 你需要显示你的控制器代码。

标签: cakephp cakephp-3.0


【解决方案1】:

仅供参考,我忘了添加序列化

$this->set('_serialize', ['data' => 'data']);

【讨论】:

    猜你喜欢
    • 2021-07-04
    • 1970-01-01
    • 2019-03-26
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2020-11-03
    相关资源
    最近更新 更多