I can not test the exception is throw in my test case even if it is the test do not pas:
Tests\Feature\QuizPageTest::test_if_questionID_is_invalid_redirect
Failed asserting that exception of type "\Illuminate\Database\Eloquent\ModelNotFoundException" is thrown.
I have in testClass:
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
/**
* @expectedException ModelNotFoundException
*
* @return
*/
public function test_if_questionID_is_invalid_redirect(){
So whatever you are sending with you request, it looks like 1000 in your test. It is never used. If you want to return a quiz based on the post variable you should retrieve that post variable within your controller.
public function addUserAnswer(Request $request)
{
$quiz = Quiz::findOrFail($request->post('question_id'));
// do whatever you need todo here.
}