Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer error reporting on seeInDatabase() #17408

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,24 @@ protected function seeInDatabase($table, array $data, $connection = null)

$count = $database->connection($connection)->table($table)->where($data)->count();

$extraInfo = '';
if (0 === $count) {
$allResults = $database->connection($connection)->table($table)->get();
$extraInfo = sprintf('%sAll entries in table "%s":%s%s',
PHP_EOL,
$table,
PHP_EOL,
json_encode($allResults, JSON_PRETTY_PRINT)
);
}

$this->assertGreaterThan(0, $count, sprintf(
'Unable to find row in database table [%s] that matched attributes [%s].', $table, json_encode($data)
'Unable to find row in database table "%s" that matched attributes: %s%s%s%s',
$table,
PHP_EOL,
json_encode($data, JSON_PRETTY_PRINT),
PHP_EOL,
$extraInfo
));

return $this;
Expand Down