普通网友 2016-05-09 18:36
浏览 54
已采纳

无法在phpunit上重新声明Laravel路由方法重复

I have my own method in route.php file in Laravel 5.2. It works but when I try to run tests on phpunit this message appear:

Fatal error: Cannot redeclare getRoutes() (previously declared in C:\(...)\ppm\app\Httpoutes.php:55) in C:\(...)\ppm\app\Httpoutes.php on line 76

My routes.php: here My UserTest.php: here

  • 写回答

3条回答 默认 最新

  • duan4523 2016-05-10 16:09
    关注

    In Laravel 5.2, changing require to require_once in App/Providers/RouteServiceProvide.php fixed the problem.

    public function map(Router $router)
    {
         $router->group(['namespace' => $this->namespace], function ($router) {
             require_once app_path('Http/routes.php');
         });
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?