I have never received an answer to this question, but have implemented work that seems to work for my testing purposes. I would like to hear feedback or get answers to these questions.
What I did was create a 2nd route for testing.
In actual use, uri will be /search/results?term=searchtermhere
For testing purposes, this did not work. I have never been able to access the meaning of a term when called using an automatic test. So, I created the 2nd route for testing only, which has uri /search/results/{searchtermhere} .
Then my action class, used for a real search, will call another function and pass this term to the function:
public function searchResultsAction() { $request = Request::createFromGlobals(); $term = trim($request->request->get('term')); return $this->searchResultsWithTermAction($term); }
So, my functional tests will be excersize searchResultsWithTermAction() , so the only code coverage that I am missing in this workaround is extracting the term from the query.
Chris source share