Skip to content

Commit

Permalink
Merge pull request #120 from sfelix-martins/analysis-peEbnR
Browse files Browse the repository at this point in the history
ci: apply fixes from StyleCI
  • Loading branch information
sfelix-martins authored Feb 10, 2020
2 parents 25fab6b + 954d75c commit f394bc3
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOauthAccessTokenProvidersTable extends Migration
{
Expand Down
2 changes: 1 addition & 1 deletion src/Facades/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SMartins\PassportMultiauth\Facades;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Symfony\Component\HttpFoundation\Request;

class ServerRequest
{
Expand Down
2 changes: 1 addition & 1 deletion src/Guards/GuardChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SMartins\PassportMultiauth\Guards;

use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;

class GuardChecker
{
Expand Down
6 changes: 3 additions & 3 deletions src/HasMultiAuthApiTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace SMartins\PassportMultiauth;

use Laravel\Passport\Token;
use Illuminate\Container\Container;
use Laravel\Passport\PersonalAccessTokenResult;
use Laravel\Passport\PersonalAccessTokenFactory;
use Laravel\Passport\HasApiTokens as BaseHasApiTokens;
use Laravel\Passport\PersonalAccessTokenFactory;
use Laravel\Passport\PersonalAccessTokenResult;
use Laravel\Passport\Token;
use SMartins\PassportMultiauth\Config\AuthConfigHelper;
use SMartins\PassportMultiauth\Exceptions\MissingConfigException;

Expand Down
21 changes: 10 additions & 11 deletions src/Http/Middleware/MultiAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
namespace SMartins\PassportMultiauth\Http\Middleware;

use Closure;
use Illuminate\Auth\RequestGuard;
use Illuminate\Foundation\Application;
use League\OAuth2\Server\ResourceServer;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Auth\Middleware\Authenticate;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Auth\RequestGuard;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth as AuthFacade;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\ResourceServer;
use Psr\Http\Message\ServerRequestInterface;
use SMartins\PassportMultiauth\Config\AuthConfigHelper;
use SMartins\PassportMultiauth\Facades\ServerRequest;
use SMartins\PassportMultiauth\Guards\GuardChecker;
use SMartins\PassportMultiauth\PassportMultiauth;
use SMartins\PassportMultiauth\Provider as Token;
use Illuminate\Support\Facades\Auth as AuthFacade;
use SMartins\PassportMultiauth\ProviderRepository;
use SMartins\PassportMultiauth\Guards\GuardChecker;
use SMartins\PassportMultiauth\Facades\ServerRequest;
use SMartins\PassportMultiauth\Config\AuthConfigHelper;
use League\OAuth2\Server\Exception\OAuthServerException;

class MultiAuthenticate extends Authenticate
{
Expand Down Expand Up @@ -105,8 +105,6 @@ public function handle($request, Closure $next, ...$guards)
if (! $guard || (isset($guardsModels[$guard]) && $user instanceof $guardsModels[$guard])) {
return $user;
}

return null;
});

// After it, we'll change the passport driver behavior to get the
Expand All @@ -116,6 +114,7 @@ public function handle($request, Closure $next, ...$guards)
'passport',
function ($app, $name, array $config) use ($request) {
$providerGuard = AuthConfigHelper::getProviderGuard($config['provider']);

return tap($this->makeGuard($request, $providerGuard), function ($guard) {
Application::getInstance()->refresh('request', $guard, 'setRequest');
});
Expand Down
11 changes: 5 additions & 6 deletions src/PassportMultiauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

namespace SMartins\PassportMultiauth;

use Mockery;
use Exception;
use Laravel\Passport\Token;
use Laravel\Passport\HasApiTokens;
use Illuminate\Support\Facades\App;
use Laravel\Passport\HasApiTokens;
use Laravel\Passport\Token;
use Mockery;
use SMartins\PassportMultiauth\Config\AuthConfigHelper;

class PassportMultiauth
{

/**
* Indicates if MultiAuth migrations will be run.
*
Expand Down Expand Up @@ -49,8 +48,8 @@ public static function actingAs($user, $scopes = [])

$uses = array_flip(class_uses_recursive($user));

if (!isset($uses[HasApiTokens::class])) {
throw new Exception('The model [' . get_class($user) . '] must uses the trait ' . HasApiTokens::class);
if (! isset($uses[HasApiTokens::class])) {
throw new Exception('The model ['.get_class($user).'] must uses the trait '.HasApiTokens::class);
}

$user->withAccessToken($token);
Expand Down
20 changes: 10 additions & 10 deletions tests/Feature/MultiauthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace SMartins\PassportMultiauth\Tests\Feature;

use Illuminate\Auth\AuthenticationException;
use Illuminate\Http\Request;
use Laravel\Passport\Client;
use Laravel\Passport\Passport;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Auth\AuthenticationException;
use SMartins\PassportMultiauth\Tests\TestCase;
use Laravel\Passport\Client;
use Laravel\Passport\Passport;
use SMartins\PassportMultiauth\Http\Middleware\AddCustomProvider;
use SMartins\PassportMultiauth\PassportMultiauth;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Company;
use SMartins\PassportMultiauth\Http\Middleware\AddCustomProvider;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Tests\TestCase;

class MultiauthTest extends TestCase
{
Expand Down Expand Up @@ -114,14 +114,14 @@ function () {
},
function () {
config(['auth.defaults.guard' => 'web']);
}
},
];

foreach ($configs as $config) {
$config();

// Two different models with same id.
$user = factory(User::class)->create();
$user = factory(User::class)->create();
$company = factory(Company::class)->create();

$this->assertEquals($user->getKey(), $company->getKey());
Expand Down Expand Up @@ -162,14 +162,14 @@ function () {
},
function () {
config(['auth.defaults.guard' => 'web']);
}
},
];

foreach ($configs as $config) {
$config();

// Two different models with same id.
$user = factory(User::class)->create();
$user = factory(User::class)->create();
$company = factory(Company::class)->create();

$this->assertEquals($user->getKey(), $company->getKey());
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Models/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SMartins\PassportMultiauth\Tests\Fixtures\Models;

use SMartins\PassportMultiauth\HasMultiAuthApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
use SMartins\PassportMultiauth\HasMultiAuthApiTokens;

class Admin extends Authenticatable
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Models/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SMartins\PassportMultiauth\Tests\Fixtures\Models;

use SMartins\PassportMultiauth\HasMultiAuthApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
use SMartins\PassportMultiauth\HasMultiAuthApiTokens;

class Company extends Authenticatable
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SMartins\PassportMultiauth\Tests\Fixtures\Models;

use SMartins\PassportMultiauth\HasMultiAuthApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
use SMartins\PassportMultiauth\HasMultiAuthApiTokens;

class User extends Authenticatable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCompaniesTable extends Migration
{
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace SMartins\PassportMultiauth\Tests;

use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
use Laravel\Passport\PassportServiceProvider;
use Orchestra\Database\ConsoleServiceProvider;
use Orchestra\Testbench\TestCase as BaseTestCase;
use SMartins\PassportMultiauth\Providers\MultiauthServiceProvider;
use SMartins\PassportMultiauth\Tests\Fixtures\Http\Kernel;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Company;
use SMartins\PassportMultiauth\Providers\MultiauthServiceProvider;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;

abstract class TestCase extends BaseTestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/AddCustomProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace SMartins\PassportMultiauth\Tests\Unit;

use Mockery;
use Illuminate\Http\Request;
use SMartins\PassportMultiauth\Tests\TestCase;
use League\OAuth2\Server\Exception\OAuthServerException;
use Mockery;
use SMartins\PassportMultiauth\Http\Middleware\AddCustomProvider;
use SMartins\PassportMultiauth\Tests\TestCase;

class AddCustomProviderTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/AuthConfigHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace SMartins\PassportMultiauth\Tests\Unit;

use SMartins\PassportMultiauth\Tests\TestCase;
use SMartins\PassportMultiauth\Config\AuthConfigHelper;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Exceptions\MissingConfigException;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Company;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Customer;
use SMartins\PassportMultiauth\Exceptions\MissingConfigException;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Tests\TestCase;

class AuthConfigHelperTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/GuardCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace SMartins\PassportMultiauth\Tests\Unit;

use Mockery;
use SMartins\PassportMultiauth\Tests\TestCase;
use SMartins\PassportMultiauth\Guards\GuardChecker;
use SMartins\PassportMultiauth\Tests\TestCase;

class GuardCheckerTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/HasApiTokensTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace SMartins\PassportMultiauth\Tests\Unit;

use SMartins\PassportMultiauth\Tests\TestCase;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Exceptions\MissingConfigException;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Admin;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Company;
use SMartins\PassportMultiauth\Exceptions\MissingConfigException;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Tests\TestCase;

class HasApiTokensTest extends TestCase
{
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/MultiAuthenticateMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace SMartins\PassportMultiauth\Tests\Unit;

use Mockery;
use Illuminate\Http\Request;
use Zend\Diactoros\ServerRequest;
use SMartins\PassportMultiauth\Provider;
use Illuminate\Auth\AuthenticationException;
use SMartins\PassportMultiauth\Tests\TestCase;
use Illuminate\Http\Request;
use League\OAuth2\Server\Exception\OAuthServerException;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Company;
use Mockery;
use SMartins\PassportMultiauth\Http\Middleware\MultiAuthenticate;
use SMartins\PassportMultiauth\Provider;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Company;
use SMartins\PassportMultiauth\Tests\TestCase;
use Zend\Diactoros\ServerRequest;

class MultiAuthenticateMiddlewareTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/PassportMultiauthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace SMartins\PassportMultiauth\Tests\Unit;

use Exception;
use SMartins\PassportMultiauth\Tests\TestCase;
use SMartins\PassportMultiauth\PassportMultiauth;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\Customer;
use SMartins\PassportMultiauth\Tests\Fixtures\Models\User;
use SMartins\PassportMultiauth\Tests\TestCase;

class PassportMultiauthTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ProviderRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace SMartins\PassportMultiauth\Tests\Unit;

use SMartins\PassportMultiauth\Provider;
use SMartins\PassportMultiauth\Tests\TestCase;
use SMartins\PassportMultiauth\ProviderRepository;
use SMartins\PassportMultiauth\Tests\TestCase;

class ProviderRepositoryTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ServerRequestFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\Request;
use SMartins\PassportMultiauth\Facades\ServerRequest;
use Symfony\Component\HttpFoundation\Request;

class ServerRequestFacadeTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace SMartins\PassportMultiauth\Tests\Unit;

use SMartins\PassportMultiauth\Provider;
use Illuminate\Database\Capsule\Manager as DB;
use SMartins\PassportMultiauth\Tests\TestCase;
use Laravel\Passport\Events\AccessTokenCreated;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Laravel\Passport\Events\AccessTokenCreated;
use SMartins\PassportMultiauth\Provider;
use SMartins\PassportMultiauth\Providers\MultiauthServiceProvider;
use SMartins\PassportMultiauth\Tests\TestCase;

class ServiceProviderTest extends TestCase
{
Expand Down

0 comments on commit f394bc3

Please sign in to comment.