2015-11-04 77 views
4

当我在Laravel Lumen中创建PHPUnit测试用例并调用visit('/')函数时,PHPUnit始终返回404错误代码。PHPUnit/Lumen始终返回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('/'); 
    } 
} 

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

在此先感谢。

回答

0

我解决了这个问题,包括我的路线,使用require而不是require_once

0

我通过将APP_URL返回到.env文件中的原始值来解决此问题。

APP_URL=http://localhost 

或者只是将其更改为您正在使用的本地主机地址。