Bir laravel rota my.route
bağlanan bir sayfa /my/example/page
bir bağlantı var link yönlendirir.Test harici sitelerde
Rota
Route::group(['middleware' => ['auth']], function() {
Route::group(['middleware' => ['Some\Custom\Auth\Middleware:1']], function() {
Route::match(['GET', 'POST'], '/my/route/to/external/controller', '[email protected]')->name('my.route');
}
}
bağlantı /my/example/page
<a href="/my/route/to/external/controller">Link</a>
kullanımı href için URL döner exampleController
denetleyicisi bu kontrol yöntemi externalLink
Bu yol /my/route/to/external/controller
sayı, ilgili
public function externalLink()
{
return $this->redirect->away('www.externalsite.com');
}
Testim ben click()
test yöntemi kullandığınızda
$this->visit(/my/example/page)
->click('Link')
->assertRedirectedToRoute('my.route');
Ben sürekli hatayı
Symfony \ Component \ HttpKernel \ İstisna \ NotFoundHttpException
olsun.
Bu @expectedException
kullanarak ama farklı sayfasını görmek için bekliyorum olarak onun yardımcı olmuyor yakalayabilirsiniz.
Ayrıca (birlikte değil) çalıştılar; url ben düğmesi tıkladım ve harici bir siteye yönlendirme ediliyor nasıl işlevsel test edebilirsiniz
http://www.example.com/my/route/to/external 302
http://www.externalsite.com 200
olsun tıklandığında
tarayıcı muayene itibaren
->assertResponseStatus(200);
->seePageIs('www.externalsite.com');
->assertRedirect();
->followRedirects();
?
Ne rota neye benziyor? – tptcat
@tptcat Soruyu güncelledim – myol