I'm pasting the output of phpStorm exception obtained from phpUnit:
Failed asserting that a row in the table [questions] matches the attributes [
"title",
"Rerum quis dolores quas sint repudiandae qui."
].
Found: [
{
"id": "1",
"user_id": "2",
"title": "Rerum quis dolores quas sint repudiandae qui.",
"body": "Nam sunt consequuntur non aut exercitationem est earum omnis. Fugiat voluptatibus eveniet laborum sunt quo debitis eveniet nam. Quo dolores itaque similique consequatur natus ipsa inventore.",
"opt1": "ipsum",
"opt2": "nulla",
"opt3": "deserunt",
"opt4": "quaerat",
"correct": "4",
"explanation": "Et ratione ea deserunt et. Qui esse quia pariatur sequi nesciunt quasi. Voluptatem sint veniam soluta id commodi ducimus. Et et nesciunt enim esse.",
"created_at": "2017-09-27 05:56:54",
"updated_at": "2017-09-27 05:56:54"
}
].
AS you can see, the 'title' field in my table actually has the required test. Yet, phpUnit informs that the test failed.
Here's how my test looks like -
/** @test */
public function an_authenticated_user_can_add_question() {
//$this->withoutExceptionHandling();
$this->signIn();
$question = create('App\Question');
$this->post('questions/create', $question->toArray() );
$this->assertDatabaseHas('questions', ['title', $question->title]);
}
Would really appreciate your help. Thanks!