【问题标题】:Laravel 5 testing undefined property $clientLaravel 5 测试未定义的属性 $client
【发布时间】:2014-12-11 13:52:14
【问题描述】:

我正在尝试使用 Laravel 5 (4.3),并尝试编写一些简单的控制器测试,如下所示:

public function testIndex()
{
   $this->call('GET', 'posts');

   $this->assertResponseOk();
}

当我运行测试时出现错误:

ErrorException:未定义属性:PostsControllerTest::$client

为什么客户端属性从 Laravel 5 的测试类中消失了?

【问题讨论】:

  • Laravel 5 甚至还没有处于测试阶段。预计事情会随机中断。

标签: php unit-testing laravel-5


【解决方案1】:

类似的功能

$this->assertResponseOk();

在当前的 Laravel 5 版本中不可用。我不确定 Taylor 是否计划重新引入它们。

我认为你可以添加以下包来恢复一些功能

https://github.com/orchestral/testbench

【讨论】:

  • 作为更新 - 这些似乎在 Laravel 5 的最新 alpha 版本中回归
猜你喜欢
  • 2015-10-09
  • 2017-07-29
  • 2021-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-23
  • 2019-06-13
  • 2016-12-29
相关资源
最近更新 更多