我正在尝试在我的Laravel应用程序中测试谷歌登录。
当我尝试进入谷歌登录页面时,我得到了404。
我的想法是,在TestCase.php中,我有一个变量:
protected $baseUrl = 'http://laravel.dev';
所以,这可能会引发冲突。。。。问题是我不知道该怎么做,也不知道该如何修复!
这是我的代码:
$this->visit('/auth/login')
->click('google');
dump(Request::url()); // https://accounts.google.com/o/oauth2/auth
$this->dump(); --> Gives me a 404 page
欢迎任何想法!
答案是否定的。框架不支持它。如果你挖掘一点,你会发现当你用"visit"测试时,请求实际上并没有发出。在MakesHttpRequests类的调用方法中,它初始化了一个laravel http内核并通过它发出请求。实际上没有发出http请求。
$kernel = $this->app->make('Illuminate'Contracts'Http'Kernel');
$this->currentUri = $this->prepareUrlForRequest($uri);
$this->resetPageContext();
$request = Request::create(
$this->currentUri, $method, $parameters,
$cookies, $files, array_replace($this->serverVariables, $server), $content
);
$response = $kernel->handle($request);
你唯一能尝试的方法就是嘲笑这个部分。