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

[5.6] Let Exception Handler do the reporting #24864

Merged
merged 3 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions src/Illuminate/Database/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\SqlServerConnection;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Debug\ExceptionHandler;

class ConnectionFactory
{
Expand Down Expand Up @@ -182,9 +181,7 @@ protected function createPdoResolverWithHosts(array $config)
try {
return $this->createConnector($config)->connect($config);
} catch (PDOException $e) {
if (count($hosts) - 1 === $key && $this->container->bound(ExceptionHandler::class)) {
$this->container->make(ExceptionHandler::class)->report($e);
}
continue;
}
}

Expand Down
51 changes: 51 additions & 0 deletions tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Illuminate\Tests\Integration\Auth\ApiAuthenticationWithEloquentTest;

use Orchestra\Testbench\TestCase;
use Illuminate\Support\Facades\Route;
use Illuminate\Database\QueryException;

class ApiAuthenticationWithEloquentTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
$app['config']->set('app.debug', 'true');

// Auth configuration
$app['config']->set('auth.defaults.guard', 'api');
$app['config']->set('auth.providers.users.model', User::class);

// Database configuration
$app['config']->set('database.default', 'testbench');

$app['config']->set('database.connections.testbench', [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'username' => 'root',
'password' => 'invalid-credentials',
'database' => 'forge',
'prefix' => '',
]);
}

/**
* @test
*/
public function authentication_via_api_with_eloquent_using_wrong_database_credentials_should_not_cause_infinite_loop()
{
Route::get('/auth', function () {
return 'success';
})->middleware('auth:api');

$this->expectException(QueryException::class);

$this->expectExceptionMessage("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from `users` where `api_token` = whatever limit 1)");

$this->withoutExceptionHandling()->get('/auth', ['Authorization' => 'Bearer whatever']);
}
}

class User extends \Illuminate\Foundation\Auth\User
{
}
2 changes: 0 additions & 2 deletions tests/Integration/Database/EloquentRelationshipsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class EloquentRelationshipsTest extends TestCase
{
/**
* @test
* @group f
*/
public function standard_relationships()
{
Expand All @@ -41,7 +40,6 @@ public function standard_relationships()

/**
* @test
* @group f
*/
public function overridden_relationships()
{
Expand Down