2016-07-22 88 views
0

我有一組API:與組前綴Laravel測試

Route::group(array('prefix' => 'api'), function() { 

    Route::get('abc', function() { 
     return 'abc'; 
    }); 
); 

但是,測試使用$this->call('GET', '/api/abc)$this->call('GET', 'path_to_abc')的時候,我總是得到404錯誤,雖然我打印的網址,我可以訪問該鏈接在瀏覽器

+0

其他路線是否在你的測試用例文件中工作? –

+0

不,我剛剛寫了1個基本測試 – maphongba008

回答

0

如果您還沒有配置您的TestCase.php文件,你需要在那裏設置你的應用程序網址爲

文件:TestCase.php

/** 
* The base URL to use while testing the application. 
* 
* @var string 
*/ 
protected $baseUrl = 'http://YOUR_APP_URL'; 
+0

不工作。我使用絕對路徑,如:http://localhost/.../abc但仍然出錯 – maphongba008