Laravel-Lumen获取带有参数的请求不起作用

时间:2019-03-23 12:24:54

标签: laravel http lumen

我在流明方面遇到了一个奇怪的问题,所有的发布和获取请求都工作正常,但是只有带有参数的获取请求没有以下错误

viewmodel

这是我的Web.php

class LocationViewModelTest {

    @get:Rule
    var instantTaskExecutorRule = InstantTaskExecutorRule()

    private lateinit var viewModel: UserLocationViewModel

    @Mock
    lateinit var findLocationSuggestionUseCase: FindLocationSuggestionUseCase

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        this.viewModel = UserLocationViewModel(
            this.findLocationSuggestionUseCase
        )
    }

    @Test
    fun searchLocationsSuccessTest() {
        viewModel.inputs.searchLocation("Test")
        Assert.assertTrue(viewModel.outputs.fetchingLocationSuggestions().value!!.equals("fetching suggestions"))

    //Here I wanna test that execute method of findLocationSuggestionUseCase is called or not
    //then I want to return Fake List of Location Suggestions
    //then I want to test that fake list of Location Suggestions reached the view 
    }


}

这是我的控制器

NotFoundHttpException

in RoutesRequests.php line 229

at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
in RoutesRequests.php line 416

如果我从路由和控制器中删除了该参数,则它正常工作,并且我在同一设备上有另一个Lumen项目,并且在所有请求下都可以正常工作!

在Mac和Apache上的即时消息

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:1)

您应该定义一条路线,例如:

$router->get('offers/{province}','OfferController@list');

而不是:

$router->get('offers/{$province}','OfferController@list');

请注意{province}的区别。