【问题标题】:Calling path helper functions inside an Unit Test setUp method throws errors在单元测试 setUp 方法中调用路径辅助函数会引发错误
【发布时间】:2021-01-01 15:08:50
【问题描述】:

使用 Laravel/Lumen 时:我显然可以在各种 PHPUnit 测试方法中引用 storage_path()、base_path() 等辅助方法,但是当我尝试在 setUp() 方法中引用它们进行测试时,我收到了以下错误:

Error : Call to undefined method Illuminate\Container\Container::basePath()

如何让这些辅助方法发挥作用?是否因为setUp() 方法受到保护而失败,而其他单元测试方法是公开的?

【问题讨论】:

    标签: laravel phpunit lumen


    【解决方案1】:

    确保您在 setUp 方法中调用 parent::setUp()

    【讨论】:

      猜你喜欢
      • 2010-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 2013-11-12
      • 2013-03-06
      • 1970-01-01
      相关资源
      最近更新 更多