I have several tests to test redirect back for form input error handling. They were working fine, but now they all fail. Heres the error message:
1) DictionaryEnjpTest::test_search_for_unknown_input_redirects_back_with_error
Did not land on expected page [http://localhost/dictionary/enjp].
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/dictionary/enjp'
+'http://localhost'
So for some reason, the tests are redirecting to '/' instead redirecting back to the previous address.
Heres one of the failing tests:
public function test_search_for_empty_input_redirects_back_with_error()
{
$this->visit('dictionary/enjp')
->type('', 'input')
->press('Search')
->seeStatusCode(200)
->seePageIs('dictionary/enjp');
$this->assertEquals(session('error_message'), Lang::get('errors.search.empty'));
}
And the controller method that deals with this redirect:
/**
* Search and display results
*
* @return Redirect
*/
public function search()
{
$data = $this->request->all();
$input = $data['input'];
if (empty($input)) {
return back()->withInput()->with('error_message', Lang::get('errors.search.empty'));
}
$results = $this->apiSearch($input);
$answer = $results['answer'];
$query = $results['query'];
if ($answer->isEmpty()) {
return back()->withInput()->with('error_message', Lang::get('errors.search.no_result'));
}
if (count($answer) === 1) {
$word = getWordFromAnswer($answer);
return redirect('/dictionary/enjp/' . $word);
}
$answer = $this->result_transformer->transformCollection($answer);
session(['answer' => $answer, 'query' => $query]);
return redirect('dictionary/enjp/results');
}
In the browser, it works fine. Until today, it worked fine. Any idea what happened? I updated my computer, if that makes any difference....