मेरे पास एक पृष्ठ /my/example/page
पर एक लिंक है जो एक लार्वेल मार्ग my.route
से लिंक करता है।बाहरी साइटों के लिए रीडायरेक्ट लिंक का परीक्षण
मार्ग
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');
}
}
लिंक /my/example/page
<a href="/my/route/to/external/controller">Link</a>
exampleController
नियंत्रक में इस नियंत्रक विधि externalLink
को इस मार्ग /my/route/to/external/controller
अंक, जो href के लिए यूआरएल रिटर्न का उपयोग करने पर
public function externalLink()
{
return $this->redirect->away('www.externalsite.com');
}
मेरा परीक्षण
$this->visit(/my/example/page)
->click('Link')
->assertRedirectedToRoute('my.route');
मैं लगातार त्रुटि
Symfony \ घटक \ HttpKernel \ अपवाद \ NotFoundHttpException
जब मैं click()
परीक्षण विधि का उपयोग मिलता है।
मैं इसे @expectedException
का उपयोग करके पकड़ सकता हूं लेकिन उसकी मदद नहीं करता क्योंकि मुझे एक अलग पृष्ठ देखने की उम्मीद है।
मैंने भी कोशिश की है (एक साथ नहीं);
->assertResponseStatus(200);
->seePageIs('www.externalsite.com');
->assertRedirect();
->followRedirects();
ब्राउज़र निरीक्षण से, जब यूआरएल क्लिक किया जाता है मैं
http://www.example.com/my/route/to/external 302
http://www.externalsite.com 200
मैं कैसे कार्यात्मक परीक्षण कर सकते हैं बटन क्लिक किया और एक बाहरी साइट के लिए पुनः निर्देशित किया जा रहा है?
क्या अपने मार्ग कैसा दिखता है? – tptcat
@tptcat मैंने प्रश्न अपडेट किया है – myol