在L4.2中,我一直在尝试使用phpunit助手assertRedirectedToRoute()
或assertRedirectedToAction()
,但是当网址上放置了其他可选参数时,它们不起作用。
例如,我有这条路线:
Route::get('properties/create/{step?}/{property_id?}', [
'as' => 'admin.properties.createStep',
'uses' => 'PropertiesController@createStep']);
但是,$this->assertRedirectedToAction(‘App\Controllers\PropertiesController@createStep’)
失败并显示以下回复:
1) AdminPropertiesTest::testSearchPostDataWithoutEANPropertyId
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/admin/properties/create'
+'http://localhost/admin/properties/create/3/194921'
如何在不在网址中声明“3”或“194921”(因为它们是动态的)并使用assertRedirectedTo()
的情况下传递断言?