我有这个测试用例:
this.instance.getPlugin('comments').setCommentAtCell(row, col, "some text comment");
// or
hot_isstance.setCommentAtCell(row, col, "some text comment");
以下中间件:
public function testRedirectToAndSetDefaultLocale()
{
$locale = config('app.locale');
$this->visit('/')->assertRedirectedTo('/' . $locale);
$this->assertEquals($locale, app()->getLocale());
}
上述测试用例失败,并带有以下跟踪:
class SetLocale
{
public function __construct(Application $app, Redirector $redirector, Request $request)
{
$this->app = $app;
$this->redirector = $redirector;
$this->request = $request;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
$locale = $request->segment(1);
if (!array_key_exists($locale, $this->app->config->get('app.locales'))) {
$segments = $request->segments();
$segments[0] = $this->app->config->get('app.fallback_locale');
return $this->redirector->to(implode('/', $segments));
}
$this->app->setLocale($locale);
return $next($request);
}
}
我假设服务器未启动或类似的东西。但是我不知道该怎么做。
编辑:
以下是我在 A request to [http://localhost:8000/en] failed. Received status code [404]./Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:196
/Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:80
/Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:138
/Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:80
/Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php:61
/Users/xxx/xxxxxxxxxx/xxxxxxxxx.project/tests/HomepageTests.php:17
中的内容:
RouteServiceProvider.php
在$locale = $this->app->request->segment(1);
$this->app->setLocale($locale);
$router->group([
'namespace' => $this->namespace,
'middleware' => 'web',
'prefix' => $locale
], function ($router) {
require app_path('Http/routes.php');
});
:
routes.php