【问题标题】:Laravel phpunit always 404Laravel phpunit 总是 404
【发布时间】:2016-11-18 09:03:28
【问题描述】:

环境:PHP 7.0 macOS apache

代码是:

public function testBasicExample()
{
    $this->visit('/');
}

运行 phpunit。 结果是:

1) ExampleTest::testBasicExample
A request to [http://localhost] failed. Received status code [404].

在 Chrome 中总是正常的。

【问题讨论】:

  • 您使用的是 vagrant 还是任何 VM?
  • 没有.......................

标签: php laravel testing phpunit


【解决方案1】:

我找到了解决这个问题的方法,就是使用

提供的 url
php artisan serve

请访问thread了解更多信息

【讨论】:

    【解决方案2】:

    您需要编辑您的TestCase.php 文件并更新

    protected $baseUrl = 'http://localhost'
    

    protected $baseUrl = 'HOST OR URL THAT YOU USE TO ACCESS YOUR SITE'
    

    【讨论】:

      猜你喜欢
      • 2016-02-04
      • 2020-11-11
      • 2016-10-10
      • 2018-05-03
      • 2020-11-30
      • 2015-07-31
      • 2021-05-16
      • 2021-02-20
      • 2016-08-16
      相关资源
      最近更新 更多