【发布时间】:2019-08-06 01:23:07
【问题描述】:
当从另一个包含命名路由的类调用方法时,无法识别该路由
这个PHPUnit测试是为了检查系统的功能是否仍然满足要求,因为系统很复杂。
从本地环境(宅基地流浪者)运行测试
我在这里调用方法表单:
$orderLines = (new EDIProcessController())->getChanges($order['ediOrder'], $order['partnerId']);
以及导致问题的命名路由:
$orderLine->item_url = route('warehouse.products.view', $itemDetails->id);
我收到以下错误:
InvalidArgumentException: Route [warehouse.products.view] not defined.
/home/vagrant/vr/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:305
/home/vagrant/vr/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:790
/home/vagrant/vr/app/Http/Controllers/Warehouse/EDI/SPS/EDIProcessController.php:1575
/home/vagrant/vr/vendor/laravel/framework/src/Illuminate/Support/Collection.php:861
/home/vagrant/vr/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php:139
/home/vagrant/vr/app/Http/Controllers/Warehouse/EDI/SPS/EDIProcessController.php:1746
路由文件中定义的路由:
Route::get('/view/{id}', 'Warehouse\ProductController@viewProduct')->name('warehouse.products.view');
当从 Laravel 应用程序中调用时,此路由工作正常,但在 PHPUnit 测试中不起作用
【问题讨论】: