【问题标题】:Template file "Error/error500.ctp" is missing. during Unit testing in CakePHP模板文件“Error/error500.ctp”丢失。在 CakePHP 的单元测试期间
【发布时间】:2019-06-16 23:55:23
【问题描述】:

我已经在我的 CakePHP 应用程序中设置了 PHPUnit,

但是当我尝试运行它时,我收到了这个错误:

Cake\View\Exception\MissingTemplateException:模板文件“Error/error500.ctp”丢失。

我已经尝试了几次 phpunit.xml.dist 页面的不同设置,但没有任何变化。

代码如下:

public function testLogin()
{
    $this->get("/admin/users/login");
    $this->assertResponseOk();
}

我尝试在 tests/TestCase/Controller/Admin/UsersControllerTest.php 中测试的非常简单的方法

【问题讨论】:

  • 请发布属于该错误的堆栈跟踪。另外,您的tests/bootstrap.php 文件是什么样的?
  • 这里是测试/bootstrap.php <?php /** * Test runner bootstrap. * * Add additional configuration/setup your application needs when running * unit tests in this file. */ require dirname(__DIR__) . '/vendor/autoload.php'; require dirname(__DIR__) . '/config/bootstrap.php'; $_SERVER['PHP_SELF'] = '/';

标签: php cakephp phpunit


【解决方案1】:

确保 error500.ctp 存在于 template/Errro/ 目录中

【讨论】:

  • 嗨,jags,是的,error500.ctp 文件存在于我的模板/错误/文件夹和模板/管理/错误/后端中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-26
  • 2023-04-07
  • 2017-11-24
  • 1970-01-01
相关资源
最近更新 更多