2015-11-04 42 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 

或者只是將其更改爲您正在使用的本地主機地址。