Laravel-测试如何修复错误Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

问题描述

我无法运行此测试方法,我想做的是只有管理员用户才能进入面板,如果该用户只是一个用户,则它必须收到状态302,但它收到404,

如果我运行php artisan route:list,我可以看到该路线

这是我的测试方法:

/** @test */
   public function usuario_no_administrador_no_puede_entrar_al_panel()
   {

           $role = factory(Role::class)->create(['name' => 'usuario']);
           $user = factory(User::class)->create();
           $user->roles()->sync($role);

           $this->actingAs($user);

           $this->withoutExceptionHandling();
           $this->get('/panel')->assertStatus(302);

   }

这是我的web.php文件:

Route::group(['middleware' => 'role:usuario','middleware' => 'role:administrador'],function() {
  Route::get('/panel','PanelController@index')->name('panel.index');
});

这是错误:

Image of error when running php artisan test

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)