gpt4 book ai didi

PHPUnit/Lumen 总是返回 404

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:44:02 26 4
gpt4 key购买 nike

当我在 Laravel Lumen 中创建一个 PHPUnit 测试用例并调用 visit('/') 函数时,PHPUnit 总是返回 404 错误代码。

我有以下代码来测试奇怪的行为:

class TestCase extends Laravel\Lumen\Testing\TestCase {
protected $baseUrl = 'https://google.com'; // this used to be my own url but even this doesn't work.

public function createApplication() {
return require __DIR__.'/../bootstrap/app.php';
}
}

class CountryTest extends TestCase {
public function testIndex() {
$this->visit('/');
}
}

有谁知道我做错了什么或如何解决这个问题?

提前致谢。

最佳答案

我通过使用 require 而不是 require_once 包含我的路由来解决这个问题。

关于PHPUnit/Lumen 总是返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33518895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com