Apply Pint fixes

This commit is contained in:
Bubka 2024-09-26 23:50:01 +02:00
parent 18fe45778a
commit c00b04e192
118 changed files with 398 additions and 458 deletions

View File

@ -6,7 +6,6 @@ use App\Api\v1\Requests\SettingStoreRequest;
use App\Api\v1\Requests\SettingUpdateRequest; use App\Api\v1\Requests\SettingUpdateRequest;
use App\Facades\Settings; use App\Facades\Settings;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Validation\ValidationException;
class SettingController extends Controller class SettingController extends Controller
{ {

View File

@ -111,8 +111,9 @@ class TwoFAccountController extends Controller
if ($twofaccount->group_id != $groupId) { if ($twofaccount->group_id != $groupId) {
if ((int) $groupId === 0) { if ((int) $groupId === 0) {
TwoFAccounts::withdraw($twofaccount->id); TwoFAccounts::withdraw($twofaccount->id);
} else {
Groups::assign($twofaccount->id, $request->user(), $groupId);
} }
else Groups::assign($twofaccount->id, $request->user(), $groupId);
$twofaccount->refresh(); $twofaccount->refresh();
} }
@ -151,7 +152,7 @@ class TwoFAccountController extends Controller
$validated = $request->validated(); $validated = $request->validated();
$twofaccounts = TwoFAccount::whereIn('id', $validated['orderedIds'])->get(); $twofaccounts = TwoFAccount::whereIn('id', $validated['orderedIds'])->get();
$this->authorize('updateEach', [new TwoFAccount(), $twofaccounts]); $this->authorize('updateEach', [new TwoFAccount, $twofaccounts]);
TwoFAccount::setNewOrder($validated['orderedIds']); TwoFAccount::setNewOrder($validated['orderedIds']);
$orderedIds = $request->user()->twofaccounts->sortBy('order_column')->pluck('id'); $orderedIds = $request->user()->twofaccounts->sortBy('order_column')->pluck('id');
@ -192,7 +193,7 @@ class TwoFAccountController extends Controller
} }
$twofaccounts = TwoFAccounts::export($validated['ids']); $twofaccounts = TwoFAccounts::export($validated['ids']);
$this->authorize('viewEach', [new TwoFAccount(), $twofaccounts]); $this->authorize('viewEach', [new TwoFAccount, $twofaccounts]);
return new TwoFAccountExportCollection($twofaccounts); return new TwoFAccountExportCollection($twofaccounts);
} }
@ -231,7 +232,7 @@ class TwoFAccountController extends Controller
// The request inputs should define an account // The request inputs should define an account
else { else {
$validatedData = $request->validate((new TwoFAccountStoreRequest)->rules()); $validatedData = $request->validate((new TwoFAccountStoreRequest)->rules());
$twofaccount = new TwoFAccount(); $twofaccount = new TwoFAccount;
$twofaccount->fillWithOtpParameters($validatedData, true); $twofaccount->fillWithOtpParameters($validatedData, true);
} }
@ -267,7 +268,7 @@ class TwoFAccountController extends Controller
$ids = Helpers::commaSeparatedToArray($validated['ids']); $ids = Helpers::commaSeparatedToArray($validated['ids']);
$twofaccounts = TwoFAccount::whereIn('id', $ids)->get(); $twofaccounts = TwoFAccount::whereIn('id', $ids)->get();
$this->authorize('updateEach', [new TwoFAccount(), $twofaccounts]); $this->authorize('updateEach', [new TwoFAccount, $twofaccounts]);
TwoFAccounts::withdraw($ids); TwoFAccounts::withdraw($ids);
@ -307,7 +308,7 @@ class TwoFAccountController extends Controller
$ids = Helpers::commaSeparatedToArray($validated['ids']); $ids = Helpers::commaSeparatedToArray($validated['ids']);
$twofaccounts = TwoFAccount::whereIn('id', $ids)->get(); $twofaccounts = TwoFAccount::whereIn('id', $ids)->get();
$this->authorize('deleteEach', [new TwoFAccount(), $twofaccounts]); $this->authorize('deleteEach', [new TwoFAccount, $twofaccounts]);
TwoFAccounts::delete($validated['ids']); TwoFAccounts::delete($validated['ids']);

View File

@ -34,15 +34,13 @@ class SettingUpdateRequest extends FormRequest
new IsValidEmailList, new IsValidEmailList,
], ],
]; ];
} } elseif ($routeParam == 'restrictRule') {
else if ($routeParam == 'restrictRule') {
$rule = [ $rule = [
'value' => [ 'value' => [
new IsValidRegex, new IsValidRegex,
], ],
]; ];
} } else {
else {
$rule = [ $rule = [
'value' => [ 'value' => [
'required', 'required',

View File

@ -37,7 +37,7 @@ class UserAuthenticationResource extends JsonResource
*/ */
public function __construct($resource) public function __construct($resource)
{ {
$this->agent = new Agent(); $this->agent = new Agent;
$this->agent->setUserAgent($resource->user_agent); $this->agent->setUserAgent($resource->user_agent);
parent::__construct($resource); parent::__construct($resource);

View File

@ -4,12 +4,8 @@ namespace App\Console\Commands\Maintenance;
use App\Facades\Settings; use App\Facades\Settings;
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use Exception;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
@ -83,8 +79,7 @@ class FixServiceFieldEncryption extends Command
$this->components->info('The Service field is fully encrypted'); $this->components->info('The Service field is fully encrypted');
return; return;
} } else {
else {
$this->newLine(); $this->newLine();
$this->components->warn('The Service field is not fully encrypted, although it should be.'); $this->components->warn('The Service field is not fully encrypted, although it should be.');
$this->line('ID of corresponding records in the twofaccounts table:'); $this->line('ID of corresponding records in the twofaccounts table:');
@ -101,10 +96,11 @@ class FixServiceFieldEncryption extends Command
$twofaccount->service = $rawServiceValue; $twofaccount->service = $rawServiceValue;
$twofaccount->save(); $twofaccount->save();
$this->components->task(sprintf('Fixing twofaccount record with ID #%s', $twofaccount->id)); $this->components->task(sprintf('Fixing twofaccount record with ID #%s', $twofaccount->id));
} } else {
else {
$error += 1; $error += 1;
$this->components->task(sprintf('Fixing twofaccount record with ID #%s', $twofaccount->id), function() { return false; }); $this->components->task(sprintf('Fixing twofaccount record with ID #%s', $twofaccount->id), function () {
return false;
});
$this->components->error('Wrong encryption key: The current APP_KEY cannot decipher already encrypted fields, encrypting the Service field with this key would lead to inconsistent data encryption'); $this->components->error('Wrong encryption key: The current APP_KEY cannot decipher already encrypted fields, encrypting the Service field with this key would lead to inconsistent data encryption');
} }
}); });
@ -116,8 +112,7 @@ class FixServiceFieldEncryption extends Command
} }
//$this->line('Task completed'); //$this->line('Task completed');
} } else {
else {
$this->components->warn('No fix applied.'); $this->components->warn('No fix applied.');
$this->line('You can re-run this command at any time to fix inconsistent records.'); $this->line('You can re-run this command at any time to fix inconsistent records.');
} }

View File

@ -82,7 +82,7 @@ trait ResetTrait
{ {
$this->callSilent('db:seed', [ $this->callSilent('db:seed', [
'--class' => $seeder, '--class' => $seeder,
'--no-interaction' => 1 '--no-interaction' => 1,
]); ]);
$this->line('Database seeded'); $this->line('Database seeded');

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class DbEncryptionException extends Exception class DbEncryptionException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class EncryptedMigrationException extends Exception class EncryptedMigrationException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class InvalidMigrationDataException extends Exception class InvalidMigrationDataException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class InvalidOtpParameterException extends Exception class InvalidOtpParameterException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class InvalidQrCodeException extends Exception class InvalidQrCodeException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class InvalidSecretException extends Exception class InvalidSecretException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class UndecipherableException extends Exception class UndecipherableException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class UnsupportedMigrationException extends Exception class UnsupportedMigrationException extends Exception {}
{
}

View File

@ -9,6 +9,4 @@ use Exception;
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class UnsupportedOtpTypeException extends Exception class UnsupportedOtpTypeException extends Exception {}
{
}

View File

@ -34,7 +34,7 @@ class MigratorFactory implements MigratorFactoryInterface
} elseif ($this->isPlainText($migrationPayload)) { } elseif ($this->isPlainText($migrationPayload)) {
return App::make(PlainTextMigrator::class); return App::make(PlainTextMigrator::class);
} else { } else {
throw new UnsupportedMigrationException(); throw new UnsupportedMigrationException;
} }
} }
@ -130,7 +130,7 @@ class MigratorFactory implements MigratorFactoryInterface
if (Arr::has($json, 'db')) { if (Arr::has($json, 'db')) {
if (is_string($json['db']) && is_array(Arr::get($json, 'header.slots'))) { if (is_string($json['db']) && is_array(Arr::get($json, 'header.slots'))) {
throw new EncryptedMigrationException(); throw new EncryptedMigrationException;
} else { } else {
return count(Validator::validate( return count(Validator::validate(
$json, $json,
@ -180,7 +180,7 @@ class MigratorFactory implements MigratorFactoryInterface
if (Arr::has($json, 'schemaVersion') && (Arr::has($json, 'services') || Arr::has($json, 'servicesEncrypted'))) { if (Arr::has($json, 'schemaVersion') && (Arr::has($json, 'services') || Arr::has($json, 'servicesEncrypted'))) {
if (Arr::has($json, 'servicesEncrypted')) { if (Arr::has($json, 'servicesEncrypted')) {
throw new EncryptedMigrationException(); throw new EncryptedMigrationException;
} else { } else {
return count(Validator::validate( return count(Validator::validate(
$json, $json,

View File

@ -54,7 +54,7 @@ class WebAuthnRecoveryController extends Controller
$user->save(); $user->save();
Log::notice(sprintf('Legacy login restored for user ID #%s', $user->id)); Log::notice(sprintf('Legacy login restored for user ID #%s', $user->id));
} else { } else {
throw new AuthenticationException(); throw new AuthenticationException;
} }
} }
); );

View File

@ -16,7 +16,7 @@ class SinglePageController extends Controller
*/ */
public function index() public function index()
{ {
event(new ScanForNewReleaseCalled()); event(new ScanForNewReleaseCalled);
$settings = Settings::all()->toJson(); $settings = Settings::all()->toJson();
$proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false; $proxyAuth = config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false;
@ -47,7 +47,7 @@ class SinglePageController extends Controller
])->toJson(), ])->toJson(),
'urls' => collect([ 'urls' => collect([
'installDocUrl' => $installDocUrl, 'installDocUrl' => $installDocUrl,
'ssoDocUrl' => $ssoDocUrl 'ssoDocUrl' => $ssoDocUrl,
]), ]),
'defaultPreferences' => $defaultPreferences, 'defaultPreferences' => $defaultPreferences,
'subdirectory' => $subdir, 'subdirectory' => $subdir,

View File

@ -70,7 +70,7 @@ class SystemController extends Controller
public function testEmail(Request $request) public function testEmail(Request $request)
{ {
try { try {
$request->user()->notify(new TestEmailSettingNotification()); $request->user()->notify(new TestEmailSettingNotification);
} catch (\Throwable $th) { } catch (\Throwable $th) {
Log::error($th->getMessage()); Log::error($th->getMessage());
} }

View File

@ -24,8 +24,9 @@ class RejectIfSsoOnlyAndNotForAdmin
if (Settings::get('useSsoOnly')) { if (Settings::get('useSsoOnly')) {
if ($email = $request->input('email', null)) { if ($email = $request->input('email', null)) {
$user = User::whereEmail($email)->first(); $user = User::whereEmail($email)->first();
} else {
$user = Auth::user();
} }
else $user = Auth::user();
if ($user?->isAdministrator()) { if ($user?->isAdministrator()) {
return $next($request); return $next($request);

View File

@ -59,7 +59,8 @@ class FailedLoginListener extends AbstractAccessListener
if ($user->preferences['notifyOnFailedLogin'] == true) { if ($user->preferences['notifyOnFailedLogin'] == true) {
$user->notify(new FailedLoginNotification($log)); $user->notify(new FailedLoginNotification($log));
} }
} } else {
else Log::info(sprintf('%s received an event with a null $user member. Nothing has been written to the auth log', self::class)); Log::info(sprintf('%s received an event with a null $user member. Nothing has been written to the auth log', self::class));
}
} }
} }

View File

@ -70,12 +70,13 @@ use Laravel\Passport\HasApiTokens;
class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthenticatable
{ {
use HasApiTokens, Notifiable; use HasApiTokens, Notifiable;
use HasAuthenticationLog; use HasAuthenticationLog;
/** /**
* @use HasFactory<UserFactory> * @use HasFactory<UserFactory>
*/ */
use HasFactory; use HasFactory;
use WebAuthnAuthentication, WebAuthnManageCredentials; use WebAuthnAuthentication, WebAuthnManageCredentials;
/** /**

View File

@ -31,7 +31,7 @@ class FailedLoginNotification extends Notification implements ShouldQueue
public function __construct(AuthLog $authLog) public function __construct(AuthLog $authLog)
{ {
$this->authLog = $authLog; $this->authLog = $authLog;
$this->agent = new Agent(); $this->agent = new Agent;
$this->agent->setUserAgent($authLog->user_agent); $this->agent->setUserAgent($authLog->user_agent);
} }
@ -48,7 +48,7 @@ class FailedLoginNotification extends Notification implements ShouldQueue
*/ */
public function toMail(mixed $notifiable) : MailMessage public function toMail(mixed $notifiable) : MailMessage
{ {
return (new MailMessage()) return (new MailMessage)
->subject(__('notifications.failed_login.subject')) ->subject(__('notifications.failed_login.subject'))
->markdown('emails.failedLogin', [ ->markdown('emails.failedLogin', [
'account' => $notifiable, 'account' => $notifiable,

View File

@ -31,7 +31,7 @@ class SignedInWithNewDeviceNotification extends Notification implements ShouldQu
public function __construct(AuthLog $authLog) public function __construct(AuthLog $authLog)
{ {
$this->authLog = $authLog; $this->authLog = $authLog;
$this->agent = new Agent(); $this->agent = new Agent;
$this->agent->setUserAgent($authLog->user_agent); $this->agent->setUserAgent($authLog->user_agent);
} }
@ -45,7 +45,7 @@ class SignedInWithNewDeviceNotification extends Notification implements ShouldQu
*/ */
public function toMail(mixed $notifiable) : MailMessage public function toMail(mixed $notifiable) : MailMessage
{ {
return (new MailMessage()) return (new MailMessage)
->subject(__('notifications.new_device.subject')) ->subject(__('notifications.new_device.subject'))
->markdown('emails.signedInWithNewDevice', [ ->markdown('emails.signedInWithNewDevice', [
'account' => $notifiable, 'account' => $notifiable,

View File

@ -26,10 +26,7 @@ class TestEmailSettingNotification extends Notification
/** /**
* TestEmailSettingNotification constructor. * TestEmailSettingNotification constructor.
*/ */
public function __construct() public function __construct() {}
{
}
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.

View File

@ -20,19 +20,19 @@ class MigrationServiceProvider extends ServiceProvider
$this->app->bind(MigratorFactoryInterface::class, MigratorFactory::class); $this->app->bind(MigratorFactoryInterface::class, MigratorFactory::class);
$this->app->singleton(GoogleAuthMigrator::class, function () { $this->app->singleton(GoogleAuthMigrator::class, function () {
return new GoogleAuthMigrator(); return new GoogleAuthMigrator;
}); });
$this->app->singleton(AegisMigrator::class, function () { $this->app->singleton(AegisMigrator::class, function () {
return new AegisMigrator(); return new AegisMigrator;
}); });
$this->app->singleton(TwoFASMigrator::class, function () { $this->app->singleton(TwoFASMigrator::class, function () {
return new TwoFASMigrator(); return new TwoFASMigrator;
}); });
$this->app->singleton(PlainTextMigrator::class, function () { $this->app->singleton(PlainTextMigrator::class, function () {
return new PlainTextMigrator(); return new PlainTextMigrator;
}); });
} }

View File

@ -23,7 +23,7 @@ class OpenId extends AbstractProvider implements ProviderInterface
public function __construct(Request $request, $clientId, $clientSecret, $redirectUrl, $guzzle = []) public function __construct(Request $request, $clientId, $clientSecret, $redirectUrl, $guzzle = [])
{ {
$guzzle = array_merge([ $guzzle = array_merge([
'proxy' => config('2fauth.config.outgoingProxy') 'proxy' => config('2fauth.config.outgoingProxy'),
], $guzzle); ], $guzzle);
parent::__construct($request, $clientId, $clientSecret, $redirectUrl, $guzzle); parent::__construct($request, $clientId, $clientSecret, $redirectUrl, $guzzle);
@ -72,7 +72,7 @@ class OpenId extends AbstractProvider implements ProviderInterface
*/ */
protected function mapUserToObject(array $user) protected function mapUserToObject(array $user)
{ {
return (new User())->setRaw($user)->map([ return (new User)->setRaw($user)->map([
'email' => $user['email'] ?? null, 'email' => $user['email'] ?? null,
'email_verified' => $user['email_verified'] ?? null, 'email_verified' => $user['email_verified'] ?? null,
'name' => $user['name'] ?? null, 'name' => $user['name'] ?? null,

View File

@ -25,15 +25,15 @@ class TwoFAuthServiceProvider extends ServiceProvider implements DeferrableProvi
}); });
$this->app->singleton(SettingService::class, function () { $this->app->singleton(SettingService::class, function () {
return new SettingService(); return new SettingService;
}); });
$this->app->singleton(LogoService::class, function () { $this->app->singleton(LogoService::class, function () {
return new LogoService(); return new LogoService;
}); });
$this->app->singleton(ReleaseRadarService::class, function () { $this->app->singleton(ReleaseRadarService::class, function () {
return new ReleaseRadarService(); return new ReleaseRadarService;
}); });
$this->app->bind(QrReader::class, function ($app, $parameters) { $this->app->bind(QrReader::class, function ($app, $parameters) {

View File

@ -18,8 +18,7 @@ class IsValidRegex implements ValidationRule
if (preg_last_error() !== PREG_NO_ERROR) { if (preg_last_error() !== PREG_NO_ERROR) {
$fail('validation.IsValidRegex')->translate(); $fail('validation.IsValidRegex')->translate();
} }
} } catch (\Throwable $ex) {
catch (\Throwable $ex) {
$fail('validation.IsValidRegex')->translate(); $fail('validation.IsValidRegex')->translate();
} }
} }

View File

@ -5,11 +5,9 @@
namespace App\Services\Auth; namespace App\Services\Auth;
use App\Events\VisitedByProxyUser;
use Illuminate\Auth\GuardHelpers; use Illuminate\Auth\GuardHelpers;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class ReverseProxyGuard implements Guard class ReverseProxyGuard implements Guard

View File

@ -41,8 +41,7 @@ class GroupService
if (! is_null($targetGroup)) { if (! is_null($targetGroup)) {
if ($targetGroup instanceof Group && $targetGroup->exists && $targetGroup->user_id == $user->id) { if ($targetGroup instanceof Group && $targetGroup->exists && $targetGroup->user_id == $user->id) {
$group = $targetGroup; $group = $targetGroup;
} } else {
else {
$group = Group::where('id', (int) $targetGroup) $group = Group::where('id', (int) $targetGroup)
->where('user_id', $user->id) ->where('user_id', $user->id)
->first(); ->first();
@ -58,7 +57,7 @@ class GroupService
$twofaccounts = TwoFAccount::find($ids); $twofaccounts = TwoFAccount::find($ids);
if ($user->cannot('updateEach', [(new TwoFAccount), $twofaccounts])) { if ($user->cannot('updateEach', [(new TwoFAccount), $twofaccounts])) {
throw new AuthorizationException(); throw new AuthorizationException;
} }
$group->twofaccounts()->saveMany($twofaccounts); $group->twofaccounts()->saveMany($twofaccounts);

View File

@ -76,7 +76,7 @@ class AegisMigrator extends Migrator
break; break;
default: default:
throw new \Exception(); throw new \Exception;
} }
$parameters['iconData'] = base64_decode($otp_parameters['icon']); $parameters['iconData'] = base64_decode($otp_parameters['icon']);
} }
@ -95,7 +95,7 @@ class AegisMigrator extends Migrator
Log::debug($exception->getMessage()); Log::debug($exception->getMessage());
// The token failed to generate a valid account so we create a fake account to be returned. // The token failed to generate a valid account so we create a fake account to be returned.
$fakeAccount = new TwoFAccount(); $fakeAccount = new TwoFAccount;
$fakeAccount->id = TwoFAccount::FAKE_ID; $fakeAccount->id = TwoFAccount::FAKE_ID;
$fakeAccount->otp_type = $otp_parameters['type'] ?? TwoFAccount::TOTP; $fakeAccount->otp_type = $otp_parameters['type'] ?? TwoFAccount::TOTP;
// Only basic fields are filled to limit the risk of another exception. // Only basic fields are filled to limit the risk of another exception.

View File

@ -28,7 +28,7 @@ class GoogleAuthMigrator extends Migrator
{ {
try { try {
$migrationData = base64_decode(urldecode(Str::replace('otpauth-migration://offline?data=', '', strval($migrationPayload)))); $migrationData = base64_decode(urldecode(Str::replace('otpauth-migration://offline?data=', '', strval($migrationPayload))));
$protobuf = new Payload(); $protobuf = new Payload;
$protobuf->mergeFromString($migrationData); $protobuf->mergeFromString($migrationData);
$otpParameters = $protobuf->getOtpParameters(); $otpParameters = $protobuf->getOtpParameters();
} catch (Exception $ex) { } catch (Exception $ex) {
@ -59,7 +59,7 @@ class GoogleAuthMigrator extends Migrator
Log::debug($exception->getMessage()); Log::debug($exception->getMessage());
// The token failed to generate a valid account so we create a fake account to be returned. // The token failed to generate a valid account so we create a fake account to be returned.
$fakeAccount = new TwoFAccount(); $fakeAccount = new TwoFAccount;
$fakeAccount->id = TwoFAccount::FAKE_ID; $fakeAccount->id = TwoFAccount::FAKE_ID;
$fakeAccount->otp_type = $fakeAccount::TOTP; $fakeAccount->otp_type = $fakeAccount::TOTP;
// Only basic fields are filled to limit the risk of another exception. // Only basic fields are filled to limit the risk of another exception.

View File

@ -37,7 +37,7 @@ class PlainTextMigrator extends Migrator
Log::debug($exception->getMessage()); Log::debug($exception->getMessage());
// The token failed to generate a valid account so we create a fake account to be returned. // The token failed to generate a valid account so we create a fake account to be returned.
$fakeAccount = new TwoFAccount(); $fakeAccount = new TwoFAccount;
$fakeAccount->id = TwoFAccount::FAKE_ID; $fakeAccount->id = TwoFAccount::FAKE_ID;
$fakeAccount->otp_type = substr($uri, 10, 4); $fakeAccount->otp_type = substr($uri, 10, 4);
// Only basic fields are filled to limit the risk of another exception. // Only basic fields are filled to limit the risk of another exception.

View File

@ -103,7 +103,7 @@ class TwoFASMigrator extends Migrator
Log::debug($exception->getMessage()); Log::debug($exception->getMessage());
// The token failed to generate a valid account so we create a fake account to be returned. // The token failed to generate a valid account so we create a fake account to be returned.
$fakeAccount = new TwoFAccount(); $fakeAccount = new TwoFAccount;
$fakeAccount->id = TwoFAccount::FAKE_ID; $fakeAccount->id = TwoFAccount::FAKE_ID;
$fakeAccount->otp_type = $otp_parameters['otp']['tokenType'] ?? TwoFAccount::TOTP; $fakeAccount->otp_type = $otp_parameters['otp']['tokenType'] ?? TwoFAccount::TOTP;
// Only basic fields are filled to limit the risk of another exception. // Only basic fields are filled to limit the risk of another exception.

View File

@ -93,7 +93,7 @@ class TwoFAuthMigrator extends Migrator
break; break;
default: default:
throw new \Exception(); throw new \Exception;
} }
$parameters['icon_file'] = base64_decode($otp_parameters['icon_file']); $parameters['icon_file'] = base64_decode($otp_parameters['icon_file']);
} }
@ -112,7 +112,7 @@ class TwoFAuthMigrator extends Migrator
Log::debug($exception->getMessage()); Log::debug($exception->getMessage());
// The token failed to generate a valid account so we create a fake account to be returned. // The token failed to generate a valid account so we create a fake account to be returned.
$fakeAccount = new TwoFAccount(); $fakeAccount = new TwoFAccount;
$fakeAccount->id = TwoFAccount::FAKE_ID; $fakeAccount->id = TwoFAccount::FAKE_ID;
$fakeAccount->otp_type = $otp_parameters['otp']['tokenType'] ?? TwoFAccount::TOTP; $fakeAccount->otp_type = $otp_parameters['otp']['tokenType'] ?? TwoFAccount::TOTP;
// Only basic fields are filled to limit the risk of another exception. // Only basic fields are filled to limit the risk of another exception.

View File

@ -41,7 +41,7 @@ class QrCodeService
{ {
$qrcode = app()->make(QrReader::class, [ $qrcode = app()->make(QrReader::class, [
'imgSource' => $file->get(), 'imgSource' => $file->get(),
'sourceType' => QrReader::SOURCE_TYPE_BLOB 'sourceType' => QrReader::SOURCE_TYPE_BLOB,
]); ]);
$text = $qrcode->text(); $text = $qrcode->text();

View File

@ -46,8 +46,9 @@ class TwoFAccountService
if ($affectedCount) { if ($affectedCount) {
Log::info(sprintf('TwoFAccounts with IDs #%s withdrawn', implode(',', $ids))); Log::info(sprintf('TwoFAccounts with IDs #%s withdrawn', implode(',', $ids)));
} else {
Log::info(sprintf('Cannot find TwoFAccounts to withdraw using ids #%s', implode(',', $ids)));
} }
else Log::info(sprintf('Cannot find TwoFAccounts to withdraw using ids #%s', implode(',', $ids)));
} }
/** /**

View File

@ -55,7 +55,7 @@ Route::group(['middleware' => ['rejectIfDemoMode', 'throttle:10,1', 'RejectIfSso
* that can be requested max 10 times per minute by the same IP * that can be requested max 10 times per minute by the same IP
*/ */
Route::group(['middleware' => ['guest', 'throttle:10,1']], function () { Route::group(['middleware' => ['guest', 'throttle:10,1']], function () {
Route::post('user/login', [LoginController::class, 'login'])->name('user.login')->middleware('RejectIfSsoOnlyAndNotForAdmin');; Route::post('user/login', [LoginController::class, 'login'])->name('user.login')->middleware('RejectIfSsoOnlyAndNotForAdmin');
Route::post('webauthn/login', [WebAuthnLoginController::class, 'login'])->name('webauthn.login')->middleware('RejectIfSsoOnlyAndNotForAdmin'); Route::post('webauthn/login', [WebAuthnLoginController::class, 'login'])->name('webauthn.login')->middleware('RejectIfSsoOnlyAndNotForAdmin');
Route::get('/socialite/redirect/{driver}', [SocialiteController::class, 'redirect'])->name('socialite.redirect'); Route::get('/socialite/redirect/{driver}', [SocialiteController::class, 'redirect'])->name('socialite.redirect');
@ -102,7 +102,7 @@ Route::get('refresh-csrf', function () {
Route::withoutMiddleware([ Route::withoutMiddleware([
SubstituteBindings::class, SubstituteBindings::class,
SetLanguage::class, SetLanguage::class,
CustomCreateFreshApiToken::class CustomCreateFreshApiToken::class,
])->get('/up', function () { ])->get('/up', function () {
//Event::dispatch(new DiagnosingHealth); //Event::dispatch(new DiagnosingHealth);
return view('health'); return view('health');

View File

@ -127,7 +127,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
'algorithm', 'algorithm',
'period', 'period',
'counter', 'counter',
'otp' => self::VALID_EMBEDDED_OTP_RESOURCE_STRUCTURE_FOR_TOTP 'otp' => self::VALID_EMBEDDED_OTP_RESOURCE_STRUCTURE_FOR_TOTP,
]; ];
private const VALID_COLLECTION_RESOURCE_STRUCTURE_WITH_OTP = [ private const VALID_COLLECTION_RESOURCE_STRUCTURE_WITH_OTP = [
@ -141,7 +141,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
'algorithm', 'algorithm',
'period', 'period',
'counter', 'counter',
'otp' => self::VALID_EMBEDDED_OTP_RESOURCE_STRUCTURE_FOR_TOTP 'otp' => self::VALID_EMBEDDED_OTP_RESOURCE_STRUCTURE_FOR_TOTP,
]; ];
private const VALID_EXPORT_STRUTURE = [ private const VALID_EXPORT_STRUTURE = [
@ -717,7 +717,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
)) ))
->assertOk() ->assertOk()
->assertJsonFragment([ ->assertJsonFragment([
'group_id' => null 'group_id' => null,
]) ])
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
} }
@ -734,7 +734,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
)) ))
->assertOk() ->assertOk()
->assertJsonFragment([ ->assertJsonFragment([
'group_id' => null 'group_id' => null,
]) ])
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
} }
@ -751,7 +751,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
)) ))
->assertOk() ->assertOk()
->assertJsonFragment([ ->assertJsonFragment([
'group_id' => $this->userGroupB->id 'group_id' => $this->userGroupB->id,
]) ])
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
} }

View File

@ -336,7 +336,7 @@ class UserManagerControllerTest extends FeatureTestCase
{ {
Artisan::call('passport:install', [ Artisan::call('passport:install', [
'--verbose' => 2, '--verbose' => 2,
'--no-interaction' => 1 '--no-interaction' => 1,
]); ]);
$tokenRepository = app(TokenRepository::class); $tokenRepository = app(TokenRepository::class);

View File

@ -1,12 +1,11 @@
<?php declare(strict_types=1); <?php
declare(strict_types=1);
namespace Tests\Api\v1\Requests\DataProviders; namespace Tests\Api\v1\Requests\DataProviders;
final class TwoFAccountDataProvider final class TwoFAccountDataProvider
{ {
/**
*
*/
public static function validIdsProvider() : array public static function validIdsProvider() : array
{ {
return [ return [
@ -19,9 +18,6 @@ final class TwoFAccountDataProvider
]; ];
} }
/**
*
*/
public static function invalidIdsProvider() : array public static function invalidIdsProvider() : array
{ {
return [ return [
@ -64,9 +60,6 @@ final class TwoFAccountDataProvider
]; ];
} }
/**
*
*/
public static function validIsAdminProvider() : array public static function validIsAdminProvider() : array
{ {
return [ return [
@ -85,9 +78,6 @@ final class TwoFAccountDataProvider
]; ];
} }
/**
*
*/
public static function invalidIsAdminProvider() : array public static function invalidIsAdminProvider() : array
{ {
return [ return [

View File

@ -26,7 +26,7 @@ class GroupAssignRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new GroupAssignRequest(); $request = new GroupAssignRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class GroupAssignRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new GroupAssignRequest(); $request = new GroupAssignRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -59,7 +59,7 @@ class GroupAssignRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new GroupAssignRequest(); $request = new GroupAssignRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -43,7 +43,7 @@ class GroupStoreRequestTest extends FeatureTestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new GroupStoreRequest(); $request = new GroupStoreRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }

View File

@ -2,7 +2,6 @@
namespace Tests\Api\v1\Requests; namespace Tests\Api\v1\Requests;
use App\Api\v1\Requests\GroupAssignRequest;
use App\Api\v1\Requests\IconFetchRequest; use App\Api\v1\Requests\IconFetchRequest;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -27,7 +26,7 @@ class IconFetchRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new IconFetchRequest(); $request = new IconFetchRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -36,7 +35,7 @@ class IconFetchRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new IconFetchRequest(); $request = new IconFetchRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -64,7 +63,7 @@ class IconFetchRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new IconFetchRequest(); $request = new IconFetchRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -27,7 +27,7 @@ class QrCodeDecodeRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new QrCodeDecodeRequest(); $request = new QrCodeDecodeRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -36,7 +36,7 @@ class QrCodeDecodeRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new QrCodeDecodeRequest(); $request = new QrCodeDecodeRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -60,7 +60,7 @@ class QrCodeDecodeRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new QrCodeDecodeRequest(); $request = new QrCodeDecodeRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -29,7 +29,7 @@ class SettingStoreRequestTest extends FeatureTestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new SettingStoreRequest(); $request = new SettingStoreRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -38,7 +38,7 @@ class SettingStoreRequestTest extends FeatureTestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new SettingStoreRequest(); $request = new SettingStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -71,7 +71,7 @@ class SettingStoreRequestTest extends FeatureTestCase
{ {
Settings::set(self::UNIQUE_KEY, 'uniqueValue'); Settings::set(self::UNIQUE_KEY, 'uniqueValue');
$request = new SettingStoreRequest(); $request = new SettingStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class SettingUpdateRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new SettingUpdateRequest(); $request = new SettingUpdateRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class SettingUpdateRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new SettingUpdateRequest(); $request = new SettingUpdateRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -63,7 +63,7 @@ class SettingUpdateRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new SettingUpdateRequest(); $request = new SettingUpdateRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -27,7 +27,7 @@ class TwoFAccountBatchRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountBatchRequest(); $request = new TwoFAccountBatchRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -36,7 +36,7 @@ class TwoFAccountBatchRequestTest extends TestCase
#[DataProviderExternal(TwoFAccountDataProvider::class, 'validIdsProvider')] #[DataProviderExternal(TwoFAccountDataProvider::class, 'validIdsProvider')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountBatchRequest(); $request = new TwoFAccountBatchRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -46,7 +46,7 @@ class TwoFAccountBatchRequestTest extends TestCase
#[DataProviderExternal(TwoFAccountDataProvider::class, 'invalidIdsProvider')] #[DataProviderExternal(TwoFAccountDataProvider::class, 'invalidIdsProvider')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountBatchRequest(); $request = new TwoFAccountBatchRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class TwoFAccountDynamicRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountDynamicRequest(); $request = new TwoFAccountDynamicRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -34,8 +34,8 @@ class TwoFAccountDynamicRequestTest extends TestCase
#[Test] #[Test]
public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input() public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input()
{ {
$twofaccountUriRequest = new TwoFAccountUriRequest(); $twofaccountUriRequest = new TwoFAccountUriRequest;
$request = new TwoFAccountDynamicRequest(); $request = new TwoFAccountDynamicRequest;
$request->merge(['uri' => 'uristring']); $request->merge(['uri' => 'uristring']);
$this->assertEquals($twofaccountUriRequest->rules(), $request->rules()); $this->assertEquals($twofaccountUriRequest->rules(), $request->rules());
@ -44,8 +44,8 @@ class TwoFAccountDynamicRequestTest extends TestCase
#[Test] #[Test]
public function test_returns_TwoFAccountStoreRequest_rules_otherwise() public function test_returns_TwoFAccountStoreRequest_rules_otherwise()
{ {
$twofaccountStoreRequest = new TwoFAccountStoreRequest(); $twofaccountStoreRequest = new TwoFAccountStoreRequest;
$request = new TwoFAccountDynamicRequest(); $request = new TwoFAccountDynamicRequest;
$this->assertEquals($twofaccountStoreRequest->rules(), $request->rules()); $this->assertEquals($twofaccountStoreRequest->rules(), $request->rules());
} }

View File

@ -26,7 +26,7 @@ class TwoFAccountImportRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountImportRequest(); $request = new TwoFAccountImportRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class TwoFAccountImportRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountImportRequest(); $request = new TwoFAccountImportRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -57,7 +57,7 @@ class TwoFAccountImportRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountImportRequest(); $request = new TwoFAccountImportRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -27,7 +27,7 @@ class TwoFAccountIndexRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountIndexRequest(); $request = new TwoFAccountIndexRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -36,7 +36,7 @@ class TwoFAccountIndexRequestTest extends TestCase
#[DataProviderExternal(TwoFAccountDataProvider::class, 'validIdsProvider')] #[DataProviderExternal(TwoFAccountDataProvider::class, 'validIdsProvider')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountIndexRequest(); $request = new TwoFAccountIndexRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -46,7 +46,7 @@ class TwoFAccountIndexRequestTest extends TestCase
#[DataProviderExternal(TwoFAccountDataProvider::class, 'invalidIdsProvider')] #[DataProviderExternal(TwoFAccountDataProvider::class, 'invalidIdsProvider')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountIndexRequest(); $request = new TwoFAccountIndexRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class TwoFAccountReorderRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountReorderRequest(); $request = new TwoFAccountReorderRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class TwoFAccountReorderRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountReorderRequest(); $request = new TwoFAccountReorderRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -60,7 +60,7 @@ class TwoFAccountReorderRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountReorderRequest(); $request = new TwoFAccountReorderRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -28,7 +28,7 @@ class TwoFAccountStoreRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountStoreRequest(); $request = new TwoFAccountStoreRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -37,7 +37,7 @@ class TwoFAccountStoreRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountStoreRequest(); $request = new TwoFAccountStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -111,7 +111,7 @@ class TwoFAccountStoreRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountStoreRequest(); $request = new TwoFAccountStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -28,7 +28,7 @@ class TwoFAccountUpdateRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountUpdateRequest(); $request = new TwoFAccountUpdateRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -37,7 +37,7 @@ class TwoFAccountUpdateRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountUpdateRequest(); $request = new TwoFAccountUpdateRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -87,7 +87,7 @@ class TwoFAccountUpdateRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountUpdateRequest(); $request = new TwoFAccountUpdateRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class TwoFAccountUriRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new TwoFAccountUriRequest(); $request = new TwoFAccountUriRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class TwoFAccountUriRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new TwoFAccountUriRequest(); $request = new TwoFAccountUriRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -64,7 +64,7 @@ class TwoFAccountUriRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new TwoFAccountUriRequest(); $request = new TwoFAccountUriRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class UserManagerPromoteRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new UserManagerPromoteRequest(); $request = new UserManagerPromoteRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class UserManagerPromoteRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new UserManagerPromoteRequest(); $request = new UserManagerPromoteRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -66,7 +66,7 @@ class UserManagerPromoteRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new UserManagerPromoteRequest(); $request = new UserManagerPromoteRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -9,7 +9,6 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\DataProviderExternal;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -28,7 +27,7 @@ class UserManagerStoreRequestTest extends FeatureTestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new UserManagerStoreRequest(); $request = new UserManagerStoreRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -42,7 +41,7 @@ class UserManagerStoreRequestTest extends FeatureTestCase
'email' => 'jane@example.com', 'email' => 'jane@example.com',
]); ]);
$request = new UserManagerStoreRequest(); $request = new UserManagerStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -80,7 +79,7 @@ class UserManagerStoreRequestTest extends FeatureTestCase
'email' => 'john@example.com', 'email' => 'john@example.com',
]); ]);
$request = new UserManagerStoreRequest(); $request = new UserManagerStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -124,7 +124,7 @@ class FixServiceFieldEncryptionTest extends FeatureTestCase
$expectedServiceName = 'myService'; $expectedServiceName = 'myService';
$twofaccounts = TwoFAccount::factory()->for($this->user)->count(3)->create([ $twofaccounts = TwoFAccount::factory()->for($this->user)->count(3)->create([
'service' => $expectedServiceName 'service' => $expectedServiceName,
]); ]);
$testedAccount = $twofaccounts[2]; $testedAccount = $twofaccounts[2];
@ -154,7 +154,7 @@ class FixServiceFieldEncryptionTest extends FeatureTestCase
$expectedServiceName = 'myService'; $expectedServiceName = 'myService';
$twofaccounts = TwoFAccount::factory()->for($this->user)->count(3)->create([ $twofaccounts = TwoFAccount::factory()->for($this->user)->count(3)->create([
'service' => $expectedServiceName 'service' => $expectedServiceName,
]); ]);
$testedAccount = $twofaccounts[2]; $testedAccount = $twofaccounts[2];

View File

@ -3,7 +3,6 @@
namespace Tests\Feature\Console; namespace Tests\Feature\Console;
use App\Console\Commands\Install; use App\Console\Commands\Install;
use Illuminate\Support\Facades\Artisan;
use Jackiedo\DotenvEditor\DotenvEditor; use Jackiedo\DotenvEditor\DotenvEditor;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
@ -101,7 +100,7 @@ class InstallTest extends FeatureTestCase
{ {
$mock = $this->mock(DotenvEditor::class); $mock = $this->mock(DotenvEditor::class);
$mock->shouldReceive('load') $mock->shouldReceive('load')
->andThrow(new \Exception()); ->andThrow(new \Exception);
$this->artisan('2fauth:install') $this->artisan('2fauth:install')
->expectsOutputToContain(config('2fauth.installDocUrl')) ->expectsOutputToContain(config('2fauth.installDocUrl'))

View File

@ -22,7 +22,7 @@ class ResetDemoTest extends FeatureTestCase
{ {
Artisan::call('passport:install', [ Artisan::call('passport:install', [
'--verbose' => 2, '--verbose' => 2,
'--no-interaction' => 1 '--no-interaction' => 1,
]); ]);
Config::set('2fauth.config.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);

View File

@ -116,13 +116,13 @@ class SocialiteControllerTest extends FeatureTestCase
{ {
return [ return [
'TOKEN_URL' => [ 'TOKEN_URL' => [
'token_url' 'token_url',
], ],
'AUTHORIZE_URL' => [ 'AUTHORIZE_URL' => [
'authorize_url' 'authorize_url',
], ],
'USERINFO_URL' => [ 'USERINFO_URL' => [
'userinfo_url' 'userinfo_url',
], ],
]; ];
} }
@ -286,7 +286,7 @@ class SocialiteControllerTest extends FeatureTestCase
$newSocialiteUser->email = 'jane@provider.com'; $newSocialiteUser->email = 'jane@provider.com';
Socialite::shouldReceive('driver->user') Socialite::shouldReceive('driver->user')
->andThrow(new Exception()); ->andThrow(new Exception);
$response = $this->get('/socialite/callback/github', ['driver' => 'github']); $response = $this->get('/socialite/callback/github', ['driver' => 'github']);

View File

@ -107,7 +107,7 @@ class WebAuthnDeviceLostControllerTest extends FeatureTestCase
{ {
$mock = $this->mock(\App\Extensions\WebauthnCredentialBroker::class)->makePartial(); $mock = $this->mock(\App\Extensions\WebauthnCredentialBroker::class)->makePartial();
$mock->shouldReceive('getUser') $mock->shouldReceive('getUser')
->andReturn(new \Illuminate\Foundation\Auth\User()); ->andReturn(new \Illuminate\Foundation\Auth\User);
Notification::fake(); Notification::fake();

View File

@ -204,7 +204,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
{ {
Notification::fake(); Notification::fake();
$this->user['preferences->notifyOnNewAuthDevice'] =01; $this->user['preferences->notifyOnNewAuthDevice'] = 0;
$this->user->save(); $this->user->save();
$this->createWebauthnCredential(self::CREDENTIAL_ID_ALT, $this->user->id, self::USER_ID_ALT); $this->createWebauthnCredential(self::CREDENTIAL_ID_ALT, $this->user->id, self::USER_ID_ALT);

View File

@ -39,7 +39,7 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase
$request = $this->mock(AttestationRequest::class); $request = $this->mock(AttestationRequest::class);
$request->expects('fastRegistration')->andReturnSelf(); $request->expects('fastRegistration')->andReturnSelf();
$request->expects('toCreate')->andReturn(new JsonTransport()); $request->expects('toCreate')->andReturn(new JsonTransport);
$this->actingAs($this->user, 'web-guard') $this->actingAs($this->user, 'web-guard')
->json('POST', '/webauthn/register/options') ->json('POST', '/webauthn/register/options')
@ -54,7 +54,7 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase
$request = $this->mock(AttestationRequest::class); $request = $this->mock(AttestationRequest::class);
$request->expects('secureRegistration')->andReturnSelf(); $request->expects('secureRegistration')->andReturnSelf();
$request->expects('toCreate')->andReturn(new JsonTransport()); $request->expects('toCreate')->andReturn(new JsonTransport);
$this->actingAs($this->user, 'web-guard') $this->actingAs($this->user, 'web-guard')
->json('POST', '/webauthn/register/options') ->json('POST', '/webauthn/register/options')

View File

@ -28,8 +28,7 @@ class AdminOnlyMiddlewareTest extends FeatureTestCase
$request = Request::create('/admin', 'GET'); $request = Request::create('/admin', 'GET');
$middleware = new AdminOnly; $middleware = new AdminOnly;
$response = $middleware->handle($request, function () { $response = $middleware->handle($request, function () {});
});
} }
#[Test] #[Test]
@ -45,8 +44,7 @@ class AdminOnlyMiddlewareTest extends FeatureTestCase
$request = Request::create('/admin', 'GET'); $request = Request::create('/admin', 'GET');
$middleware = new AdminOnly; $middleware = new AdminOnly;
$response = $middleware->handle($request, function () { $response = $middleware->handle($request, function () {});
});
$this->assertNull($response); $this->assertNull($response);
} }

View File

@ -36,7 +36,7 @@ class RejectIfSsoOnlyAndNotForAdminMiddlewareTest extends FeatureTestCase
$this->user = User::factory()->create(); $this->user = User::factory()->create();
$this->admin = User::factory()->administrator()->create([ $this->admin = User::factory()->administrator()->create([
'password' => self::PASSWORD 'password' => self::PASSWORD,
]); ]);
Settings::set('useSsoOnly', true); Settings::set('useSsoOnly', true);

View File

@ -22,7 +22,7 @@ class LoginRequestTest extends FeatureTestCase
#[Test] #[Test]
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
$request = new LoginRequest(); $request = new LoginRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class LoginRequestTest extends FeatureTestCase
'email' => 'JOHN.DOE@example.com', 'email' => 'JOHN.DOE@example.com',
]); ]);
$request = new LoginRequest(); $request = new LoginRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -66,7 +66,7 @@ class LoginRequestTest extends FeatureTestCase
'email' => 'JOHN.DOE@example.com', 'email' => 'JOHN.DOE@example.com',
]); ]);
$request = new LoginRequest(); $request = new LoginRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class UserDeleteRequestTest extends FeatureTestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new UserDeleteRequest(); $request = new UserDeleteRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class UserDeleteRequestTest extends FeatureTestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new UserDeleteRequest(); $request = new UserDeleteRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -57,7 +57,7 @@ class UserDeleteRequestTest extends FeatureTestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new UserDeleteRequest(); $request = new UserDeleteRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class UserPatchPwdRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new UserPatchPwdRequest(); $request = new UserPatchPwdRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class UserPatchPwdRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new UserPatchPwdRequest(); $request = new UserPatchPwdRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -59,7 +59,7 @@ class UserPatchPwdRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new UserPatchPwdRequest(); $request = new UserPatchPwdRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -22,7 +22,7 @@ class UserStoreRequestTest extends FeatureTestCase
#[Test] #[Test]
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
$request = new UserStoreRequest(); $request = new UserStoreRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -36,7 +36,7 @@ class UserStoreRequestTest extends FeatureTestCase
'email' => 'jane@example.com', 'email' => 'jane@example.com',
]); ]);
$request = new UserStoreRequest(); $request = new UserStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -72,7 +72,7 @@ class UserStoreRequestTest extends FeatureTestCase
'email' => 'john@example.com', 'email' => 'john@example.com',
]); ]);
$request = new UserStoreRequest(); $request = new UserStoreRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -28,7 +28,7 @@ class UserUpdateRequestTest extends FeatureTestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new UserUpdateRequest(); $request = new UserUpdateRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }

View File

@ -22,7 +22,7 @@ class WebauthnAssertedRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new WebauthnAssertedRequest(); $request = new WebauthnAssertedRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -53,7 +53,7 @@ class WebauthnAssertedRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new WebauthnAssertedRequest(); $request = new WebauthnAssertedRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -26,7 +26,7 @@ class WebauthnRenameRequestTest extends TestCase
->once() ->once()
->andReturn(true); ->andReturn(true);
$request = new WebauthnRenameRequest(); $request = new WebauthnRenameRequest;
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
@ -35,7 +35,7 @@ class WebauthnRenameRequestTest extends TestCase
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
$request = new WebauthnRenameRequest(); $request = new WebauthnRenameRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertFalse($validator->fails()); $this->assertFalse($validator->fails());
@ -57,7 +57,7 @@ class WebauthnRenameRequestTest extends TestCase
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {
$request = new WebauthnRenameRequest(); $request = new WebauthnRenameRequest;
$validator = Validator::make($data, $request->rules()); $validator = Validator::make($data, $request->rules());
$this->assertTrue($validator->fails()); $this->assertTrue($validator->fails());

View File

@ -143,7 +143,7 @@ class SystemControllerTest extends FeatureTestCase
{ {
Notification::fake(); Notification::fake();
$this->mock(Dispatcher::class)->shouldReceive('send')->andThrow(new Exception()); $this->mock(Dispatcher::class)->shouldReceive('send')->andThrow(new Exception);
$response = $this->actingAs($this->admin, 'web-guard') $response = $this->actingAs($this->admin, 'web-guard')
->json('POST', '/system/test-email', []); ->json('POST', '/system/test-email', []);

View File

@ -109,7 +109,7 @@ class UserModelTest extends FeatureTestCase
{ {
Artisan::call('passport:install', [ Artisan::call('passport:install', [
'--verbose' => 2, '--verbose' => 2,
'--no-interaction' => 1 '--no-interaction' => 1,
]); ]);
$user = User::factory()->create(); $user = User::factory()->create();
@ -446,6 +446,4 @@ class UserModelTest extends FeatureTestCase
$this->assertNull($previousLoginIp); $this->assertNull($previousLoginIp);
} }
} }

View File

@ -31,7 +31,6 @@ class FailedLoginNotificationTest extends FeatureTestCase
*/ */
protected $failedLogin; protected $failedLogin;
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -78,5 +77,4 @@ class FailedLoginNotificationTest extends FeatureTestCase
$mail $mail
); );
} }
} }

View File

@ -31,7 +31,6 @@ class SignedInWithNewDeviceNotificationTest extends FeatureTestCase
*/ */
protected $signedInWithNewDevice; protected $signedInWithNewDevice;
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -77,5 +76,4 @@ class SignedInWithNewDeviceNotificationTest extends FeatureTestCase
$mail $mail
); );
} }
} }

View File

@ -25,7 +25,6 @@ class TestEmailSettingNotificationTest extends FeatureTestCase
*/ */
protected $testEmailSettingNotification; protected $testEmailSettingNotification;
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();

View File

@ -77,5 +77,4 @@ class WebauthnRecoveryNotificationTest extends FeatureTestCase
$mail $mail
); );
} }
} }

View File

@ -4,8 +4,8 @@ namespace Tests\Feature;
use App\Providers\RouteServiceProvider; use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
@ -15,6 +15,7 @@ use Tests\FeatureTestCase;
class RouteTest extends FeatureTestCase class RouteTest extends FeatureTestCase
{ {
const API_ROUTE_PREFIX = 'api/v1'; const API_ROUTE_PREFIX = 'api/v1';
const API_MIDDLEWARE = 'api.v1'; const API_MIDDLEWARE = 'api.v1';
#[Test] #[Test]
@ -61,9 +62,7 @@ class RouteTest extends FeatureTestCase
public static function wherePatternProvider() public static function wherePatternProvider()
{ {
return [ return [
'SETTING_NAME' => ['settingName'] 'SETTING_NAME' => ['settingName'],
]; ];
} }
} }

View File

@ -39,7 +39,7 @@ class LogoServiceTest extends TestCase
Storage::fake('icons'); Storage::fake('icons');
Storage::fake('logos'); Storage::fake('logos');
$logoService = new LogoService(); $logoService = new LogoService;
$icon = $logoService->getIcon('twitter'); $icon = $logoService->getIcon('twitter');
$this->assertNotNull($icon); $this->assertNotNull($icon);
@ -56,7 +56,7 @@ class LogoServiceTest extends TestCase
Storage::fake('icons'); Storage::fake('icons');
Storage::fake('logos'); Storage::fake('logos');
$logoService = new LogoService(); $logoService = new LogoService;
$icon = $logoService->getIcon('twitter'); $icon = $logoService->getIcon('twitter');
@ -75,7 +75,7 @@ class LogoServiceTest extends TestCase
Storage::fake('icons'); Storage::fake('icons');
Storage::fake('logos'); Storage::fake('logos');
$logoService = new LogoService(); $logoService = new LogoService;
$icon = $logoService->getIcon('twitter'); $icon = $logoService->getIcon('twitter');
@ -85,7 +85,7 @@ class LogoServiceTest extends TestCase
#[Test] #[Test]
public function test_getIcon_returns_null_when_no_logo_exists() public function test_getIcon_returns_null_when_no_logo_exists()
{ {
$logoService = new LogoService(); $logoService = new LogoService;
$icon = $logoService->getIcon('no_logo_should_exists_with_this_name'); $icon = $logoService->getIcon('no_logo_should_exists_with_this_name');
@ -105,7 +105,7 @@ class LogoServiceTest extends TestCase
Storage::fake('icons'); Storage::fake('icons');
Storage::fake('logos'); Storage::fake('logos');
$logoService = new LogoService(); $logoService = new LogoService;
$icon = $logoService->getIcon('twitter'); $icon = $logoService->getIcon('twitter');
$this->assertNull($icon); $this->assertNull($icon);

View File

@ -77,16 +77,13 @@ class QrCodeServiceTest extends FeatureTestCase
QrCode::decode(LocalFile::fake()->validQrcode()); QrCode::decode(LocalFile::fake()->validQrcode());
} }
/**
*
*/
public static function QrReaderExceptionProvider() public static function QrReaderExceptionProvider()
{ {
return [ return [
'NotFoundException' => [new NotFoundException()], 'NotFoundException' => [new NotFoundException],
'FormatException' => [new FormatException()], 'FormatException' => [new FormatException],
'ChecksumException' => [new ChecksumException()], 'ChecksumException' => [new ChecksumException],
'default' => [new Exception()], 'default' => [new Exception],
]; ];
} }
} }

View File

@ -337,7 +337,7 @@ class SettingServiceTest extends FeatureTestCase
Cache::shouldReceive('remember') Cache::shouldReceive('remember')
->andReturn(collect([])); ->andReturn(collect([]));
$settingService = new SettingService(); $settingService = new SettingService;
Cache::shouldHaveReceived('remember'); Cache::shouldHaveReceived('remember');
} }
@ -348,7 +348,7 @@ class SettingServiceTest extends FeatureTestCase
Cache::shouldReceive('remember', 'put') Cache::shouldReceive('remember', 'put')
->andReturn(collect([]), true); ->andReturn(collect([]), true);
$settingService = new SettingService(); $settingService = new SettingService;
$settingService->set(self::SETTING_NAME, self::SETTING_VALUE_STRING); $settingService->set(self::SETTING_NAME, self::SETTING_VALUE_STRING);
Cache::shouldHaveReceived('put'); Cache::shouldHaveReceived('put');
@ -360,7 +360,7 @@ class SettingServiceTest extends FeatureTestCase
Cache::shouldReceive('remember', 'put') Cache::shouldReceive('remember', 'put')
->andReturn(collect([]), true); ->andReturn(collect([]), true);
$settingService = new SettingService(); $settingService = new SettingService;
$settingService->delete(self::SETTING_NAME); $settingService->delete(self::SETTING_NAME);
Cache::shouldHaveReceived('put'); Cache::shouldHaveReceived('put');

View File

@ -45,6 +45,4 @@ class ViewTest extends FeatureTestCase
Event::assertDispatched(ScanForNewReleaseCalled::class); Event::assertDispatched(ScanForNewReleaseCalled::class);
} }
} }

View File

@ -4,7 +4,6 @@ namespace Tests;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase; use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase; use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\Artisan;
abstract class FeatureTestCase extends BaseTestCase abstract class FeatureTestCase extends BaseTestCase
{ {

View File

@ -34,7 +34,7 @@ class GroupControllerTest extends TestCase
{ {
parent::setUp(); parent::setUp();
$this->user = new User(); $this->user = new User;
// We do not use $this->actingAs($this->user) to prevent intelephense // We do not use $this->actingAs($this->user) to prevent intelephense
// static analysis error. Dumb, but I don't like errors... // static analysis error. Dumb, but I don't like errors...
@ -48,7 +48,7 @@ class GroupControllerTest extends TestCase
$user = Mockery::mock(User::class); $user = Mockery::mock(User::class);
$request = Mockery::mock(Request::class); $request = Mockery::mock(Request::class);
$groups = Group::factory()->count(3)->make(); $groups = Group::factory()->count(3)->make();
$controller = new GroupController(); $controller = new GroupController;
$user->shouldReceive('groups->withCount->get') $user->shouldReceive('groups->withCount->get')
->once() ->once()
@ -70,7 +70,7 @@ class GroupControllerTest extends TestCase
public function test_store_uses_validated_data_and_returns_api_resource() public function test_store_uses_validated_data_and_returns_api_resource()
{ {
$request = Mockery::mock(GroupStoreRequest::class); $request = Mockery::mock(GroupStoreRequest::class);
$controller = new GroupController(); $controller = new GroupController;
$group = Group::factory()->for($this->user)->make(); $group = Group::factory()->for($this->user)->make();
$validated = ['name' => $group->name]; $validated = ['name' => $group->name];

View File

@ -17,7 +17,7 @@ class VisitedByProxyUserTest extends TestCase
#[Test] #[Test]
public function test_event_constructor() public function test_event_constructor()
{ {
$user = new User(); $user = new User;
$event = new VisitedByProxyUser($user); $event = new VisitedByProxyUser($user);
$this->assertSame($user, $event->user); $this->assertSame($user, $event->user);

View File

@ -36,7 +36,7 @@ class HandlerTest extends TestCase
$method = $class->getMethod('render'); $method = $class->getMethod('render');
$method->setAccessible(true); $method->setAccessible(true);
$response = $method->invokeArgs($instance, [new Request(), $this->createMock($exception)]); $response = $method->invokeArgs($instance, [new Request, $this->createMock($exception)]);
$this->assertInstanceOf(JsonResponse::class, $response); $this->assertInstanceOf(JsonResponse::class, $response);
@ -93,7 +93,7 @@ class HandlerTest extends TestCase
$method = $class->getMethod('render'); $method = $class->getMethod('render');
$method->setAccessible(true); $method->setAccessible(true);
$response = $method->invokeArgs($instance, [new Request(), $this->createMock($exception)]); $response = $method->invokeArgs($instance, [new Request, $this->createMock($exception)]);
$this->assertInstanceOf(JsonResponse::class, $response); $this->assertInstanceOf(JsonResponse::class, $response);
@ -131,7 +131,7 @@ class HandlerTest extends TestCase
$mockException = $this->createMock(\Illuminate\Auth\AuthenticationException::class); $mockException = $this->createMock(\Illuminate\Auth\AuthenticationException::class);
$mockException->method('guards')->willReturn(['web-guard']); $mockException->method('guards')->willReturn(['web-guard']);
$response = $method->invokeArgs($instance, [new Request(), $mockException]); $response = $method->invokeArgs($instance, [new Request, $mockException]);
$this->assertInstanceOf(JsonResponse::class, $response); $this->assertInstanceOf(JsonResponse::class, $response);
@ -154,7 +154,7 @@ class HandlerTest extends TestCase
$mockException = $this->createMock(\Illuminate\Auth\AuthenticationException::class); $mockException = $this->createMock(\Illuminate\Auth\AuthenticationException::class);
$mockException->method('guards')->willReturn(['reverse-proxy-guard']); $mockException->method('guards')->willReturn(['reverse-proxy-guard']);
$response = $method->invokeArgs($instance, [new Request(), $mockException]); $response = $method->invokeArgs($instance, [new Request, $mockException]);
$this->assertInstanceOf(JsonResponse::class, $response); $this->assertInstanceOf(JsonResponse::class, $response);
@ -176,7 +176,7 @@ class HandlerTest extends TestCase
$mockException = $this->createMock(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); $mockException = $this->createMock(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class);
$response = $method->invokeArgs($instance, [new Request(), $mockException]); $response = $method->invokeArgs($instance, [new Request, $mockException]);
$this->assertInstanceOf(JsonResponse::class, $response); $this->assertInstanceOf(JsonResponse::class, $response);

View File

@ -21,7 +21,7 @@ class GroupModelTest extends ModelTestCase
public function test_model_configuration() public function test_model_configuration()
{ {
$this->runConfigurationAssertions( $this->runConfigurationAssertions(
new Group(), new Group,
['name'], ['name'],
['created_at', 'updated_at'], ['created_at', 'updated_at'],
['*'], ['*'],
@ -41,9 +41,9 @@ class GroupModelTest extends ModelTestCase
#[Test] #[Test]
public function test_twofaccounts_relation() public function test_twofaccounts_relation()
{ {
$group = new Group(); $group = new Group;
$accounts = $group->twofaccounts(); $accounts = $group->twofaccounts();
$this->assertHasManyRelation($accounts, $group, new TwoFAccount()); $this->assertHasManyRelation($accounts, $group, new TwoFAccount);
} }
#[Test] #[Test]

View File

@ -55,5 +55,4 @@ class FailedLoginListenerTest extends TestCase
Notification::assertNothingSent(); Notification::assertNothingSent();
} }
} }

View File

@ -41,5 +41,4 @@ class LoginListenerTest extends TestCase
$listener->handle($event); $listener->handle($event);
} }
} }

View File

@ -29,7 +29,7 @@ class CleanIconStorageTest extends TestCase
$twofaccount = TwoFAccount::factory()->make(); $twofaccount = TwoFAccount::factory()->make();
$event = new TwoFAccountDeleted($twofaccount); $event = new TwoFAccountDeleted($twofaccount);
$listener = new CleanIconStorage(); $listener = new CleanIconStorage;
Storage::shouldReceive('disk->delete') Storage::shouldReceive('disk->delete')
->with($event->twofaccount->icon) ->with($event->twofaccount->icon)

View File

@ -32,8 +32,8 @@ class LogNotificationTest extends TestCase
#[Test] #[Test]
public function test_handle_logs_notification_sending() public function test_handle_logs_notification_sending()
{ {
$event = new NotificationSent((new User()), (new TestEmailSettingNotification()), 'channel'); $event = new NotificationSent((new User), (new TestEmailSettingNotification), 'channel');
$listener = new LogNotificationListener(); $listener = new LogNotificationListener;
Log::shouldReceive('info')->once(); Log::shouldReceive('info')->once();

View File

@ -24,8 +24,8 @@ class ReleaseRadarTest extends TestCase
$releaseRadarService->shouldReceive('scheduledScan'); $releaseRadarService->shouldReceive('scheduledScan');
}); });
$event = new ScanForNewReleaseCalled(); $event = new ScanForNewReleaseCalled;
$listener = new ReleaseRadar(); $listener = new ReleaseRadar;
$this->assertNull($listener->handle($event)); $this->assertNull($listener->handle($event));
} }

View File

@ -20,8 +20,8 @@ use Illuminate\Support\Facades\Storage;
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\UsesClass;
use Tests\Data\MigrationTestData; use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\TestCase; use Tests\TestCase;
@ -189,37 +189,37 @@ class MigratorTest extends TestCase
{ {
return [ return [
'PLAIN_TEXT_PAYLOAD' => [ 'PLAIN_TEXT_PAYLOAD' => [
new PlainTextMigrator(), new PlainTextMigrator,
MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD, MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD,
'custom', 'custom',
$hasSteam = true, $hasSteam = true,
], ],
'PLAIN_TEXT_PAYLOAD_WITH_INTRUDER' => [ 'PLAIN_TEXT_PAYLOAD_WITH_INTRUDER' => [
new PlainTextMigrator(), new PlainTextMigrator,
MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD_WITH_INTRUDER, MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD_WITH_INTRUDER,
'custom', 'custom',
$hasSteam = true, $hasSteam = true,
], ],
'AEGIS_JSON_MIGRATION_PAYLOAD' => [ 'AEGIS_JSON_MIGRATION_PAYLOAD' => [
new AegisMigrator(), new AegisMigrator,
MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD, MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD,
'custom', 'custom',
$hasSteam = true, $hasSteam = true,
], ],
'2FAS_MIGRATION_PAYLOAD' => [ '2FAS_MIGRATION_PAYLOAD' => [
new TwoFASMigrator(), new TwoFASMigrator,
MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD, MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD,
'custom', 'custom',
$hasSteam = false, $hasSteam = false,
], ],
'GOOGLE_AUTH_MIGRATION_PAYLOAD' => [ 'GOOGLE_AUTH_MIGRATION_PAYLOAD' => [
new GoogleAuthMigrator(), new GoogleAuthMigrator,
MigrationTestData::GOOGLE_AUTH_MIGRATION_URI, MigrationTestData::GOOGLE_AUTH_MIGRATION_URI,
'gauth', 'gauth',
$hasSteam = false, $hasSteam = false,
], ],
'2FAUTH_MIGRATION_PAYLOAD' => [ '2FAUTH_MIGRATION_PAYLOAD' => [
new TwoFAuthMigrator(), new TwoFAuthMigrator,
MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD, MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD,
'custom', 'custom',
$hasSteam = true, $hasSteam = true,
@ -243,51 +243,51 @@ class MigratorTest extends TestCase
{ {
return [ return [
'INVALID_PLAIN_TEXT_NO_URI' => [ 'INVALID_PLAIN_TEXT_NO_URI' => [
new PlainTextMigrator(), new PlainTextMigrator,
MigrationTestData::INVALID_PLAIN_TEXT_NO_URI, MigrationTestData::INVALID_PLAIN_TEXT_NO_URI,
], ],
'INVALID_PLAIN_TEXT_ONLY_EMPTY_LINES' => [ 'INVALID_PLAIN_TEXT_ONLY_EMPTY_LINES' => [
new PlainTextMigrator(), new PlainTextMigrator,
MigrationTestData::INVALID_PLAIN_TEXT_ONLY_EMPTY_LINES, MigrationTestData::INVALID_PLAIN_TEXT_ONLY_EMPTY_LINES,
], ],
'INVALID_PLAIN_TEXT_NULL' => [ 'INVALID_PLAIN_TEXT_NULL' => [
new PlainTextMigrator(), new PlainTextMigrator,
null, null,
], ],
'INVALID_PLAIN_TEXT_EMPTY_STRING' => [ 'INVALID_PLAIN_TEXT_EMPTY_STRING' => [
new PlainTextMigrator(), new PlainTextMigrator,
'', '',
], ],
'INVALID_PLAIN_TEXT_INT' => [ 'INVALID_PLAIN_TEXT_INT' => [
new PlainTextMigrator(), new PlainTextMigrator,
10, 10,
], ],
'INVALID_PLAIN_TEXT_BOOL' => [ 'INVALID_PLAIN_TEXT_BOOL' => [
new PlainTextMigrator(), new PlainTextMigrator,
true, true,
], ],
'INVALID_AEGIS_JSON_MIGRATION_PAYLOAD' => [ 'INVALID_AEGIS_JSON_MIGRATION_PAYLOAD' => [
new AegisMigrator(), new AegisMigrator,
MigrationTestData::INVALID_AEGIS_JSON_MIGRATION_PAYLOAD, MigrationTestData::INVALID_AEGIS_JSON_MIGRATION_PAYLOAD,
], ],
'ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD' => [ 'ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD' => [
new AegisMigrator(), new AegisMigrator,
MigrationTestData::ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD, MigrationTestData::ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD,
], ],
'INVALID_2FAS_MIGRATION_PAYLOAD' => [ 'INVALID_2FAS_MIGRATION_PAYLOAD' => [
new TwoFASMigrator(), new TwoFASMigrator,
MigrationTestData::INVALID_2FAS_MIGRATION_PAYLOAD, MigrationTestData::INVALID_2FAS_MIGRATION_PAYLOAD,
], ],
'INVALID_GOOGLE_AUTH_MIGRATION_URI' => [ 'INVALID_GOOGLE_AUTH_MIGRATION_URI' => [
new GoogleAuthMigrator(), new GoogleAuthMigrator,
MigrationTestData::INVALID_GOOGLE_AUTH_MIGRATION_URI, MigrationTestData::INVALID_GOOGLE_AUTH_MIGRATION_URI,
], ],
'GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA' => [ 'GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA' => [
new GoogleAuthMigrator(), new GoogleAuthMigrator,
MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA, MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA,
], ],
'INVALID_2FAUTH_JSON_MIGRATION_PAYLOAD' => [ 'INVALID_2FAUTH_JSON_MIGRATION_PAYLOAD' => [
new TwoFAuthMigrator(), new TwoFAuthMigrator,
MigrationTestData::INVALID_2FAUTH_JSON_MIGRATION_PAYLOAD, MigrationTestData::INVALID_2FAUTH_JSON_MIGRATION_PAYLOAD,
], ],
@ -316,19 +316,19 @@ class MigratorTest extends TestCase
{ {
return [ return [
'PLAIN_TEXT_PAYLOAD_WITH_INVALID_URI' => [ 'PLAIN_TEXT_PAYLOAD_WITH_INVALID_URI' => [
new PlainTextMigrator(), new PlainTextMigrator,
MigrationTestData::PLAIN_TEXT_PAYLOAD_WITH_INVALID_URI, MigrationTestData::PLAIN_TEXT_PAYLOAD_WITH_INVALID_URI,
], ],
'VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [ 'VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [
new AegisMigrator(), new AegisMigrator,
MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE, MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE,
], ],
'VALID_2FAS_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [ 'VALID_2FAS_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [
new TwoFASMigrator(), new TwoFASMigrator,
MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE, MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE,
], ],
'VALID_2FAUTH_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [ 'VALID_2FAUTH_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [
new TwoFAuthMigrator(), new TwoFAuthMigrator,
MigrationTestData::VALID_2FAUTH_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE, MigrationTestData::VALID_2FAUTH_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE,
], ],
]; ];
@ -339,7 +339,7 @@ class MigratorTest extends TestCase
{ {
$migrator = $this->partialMock(GoogleAuthMigrator::class, function (MockInterface $migrator) { $migrator = $this->partialMock(GoogleAuthMigrator::class, function (MockInterface $migrator) {
$migrator->shouldAllowMockingProtectedMethods()->shouldReceive('toBase32') $migrator->shouldAllowMockingProtectedMethods()->shouldReceive('toBase32')
->andThrow(new \Exception()); ->andThrow(new \Exception);
}); });
/** @disregard Undefined function */ /** @disregard Undefined function */
@ -362,7 +362,7 @@ class MigratorTest extends TestCase
{ {
Storage::fake('icons'); Storage::fake('icons');
$migrator = new AegisMigrator(); $migrator = new AegisMigrator;
$accounts = $migrator->migrate($migration); $accounts = $migrator->migrate($migration);
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts); $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
@ -394,7 +394,7 @@ class MigratorTest extends TestCase
{ {
Storage::fake('icons'); Storage::fake('icons');
$migrator = new AegisMigrator(); $migrator = new AegisMigrator;
$accounts = $migrator->migrate(MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON); $accounts = $migrator->migrate(MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON);
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts); $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
@ -410,7 +410,7 @@ class MigratorTest extends TestCase
{ {
Storage::fake('icons'); Storage::fake('icons');
$migrator = new TwoFAuthMigrator(); $migrator = new TwoFAuthMigrator;
$accounts = $migrator->migrate($migration); $accounts = $migrator->migrate($migration);
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts); $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
@ -451,7 +451,7 @@ class MigratorTest extends TestCase
{ {
Storage::fake('icons'); Storage::fake('icons');
$migrator = new TwoFAuthMigrator(); $migrator = new TwoFAuthMigrator;
$accounts = $migrator->migrate(MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON); $accounts = $migrator->migrate(MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON);
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts); $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
@ -465,7 +465,7 @@ class MigratorTest extends TestCase
#[DataProvider('factoryProvider')] #[DataProvider('factoryProvider')]
public function test_factory_returns_relevant_migrator($payload, $migratorClass) public function test_factory_returns_relevant_migrator($payload, $migratorClass)
{ {
$factory = new MigratorFactory(); $factory = new MigratorFactory;
$migrator = $factory->create($payload); $migrator = $factory->create($payload);
@ -509,7 +509,7 @@ class MigratorTest extends TestCase
public function test_factory_throw_UnsupportedMigrationException() public function test_factory_throw_UnsupportedMigrationException()
{ {
$this->expectException(UnsupportedMigrationException::class); $this->expectException(UnsupportedMigrationException::class);
$factory = new MigratorFactory(); $factory = new MigratorFactory;
$migrator = $factory->create('not_a_valid_payload'); $migrator = $factory->create('not_a_valid_payload');
} }
@ -520,7 +520,7 @@ class MigratorTest extends TestCase
{ {
$this->expectException(EncryptedMigrationException::class); $this->expectException(EncryptedMigrationException::class);
$factory = new MigratorFactory(); $factory = new MigratorFactory;
$migrator = $factory->create($payload); $migrator = $factory->create($payload);
} }

View File

@ -3,8 +3,8 @@
namespace Tests\Unit\Providers\Socialite; namespace Tests\Unit\Providers\Socialite;
use App\Providers\Socialite\OpenId; use App\Providers\Socialite\OpenId;
use SocialiteProviders\Manager\OAuth2\User;
use Mockery; use Mockery;
use SocialiteProviders\Manager\OAuth2\User;
use stdClass; use stdClass;
class OpenIdProviderStub extends OpenId class OpenIdProviderStub extends OpenId

View File

@ -29,7 +29,7 @@ class OpenIdProviderTest extends TestCase
$provider->stateless(); $provider->stateless();
$provider->http = Mockery::mock(stdClass::class); $provider->http = Mockery::mock(stdClass::class);
$provider->http->expects('get')->with(NULL, [ $provider->http->expects('get')->with(null, [
RequestOptions::HEADERS => [ RequestOptions::HEADERS => [
'Authorization' => 'Bearer access_token', 'Authorization' => 'Bearer access_token',
], ],
@ -59,7 +59,7 @@ class OpenIdProviderTest extends TestCase
$provider->stateless(); $provider->stateless();
$provider->http = Mockery::mock(stdClass::class); $provider->http = Mockery::mock(stdClass::class);
$provider->http->expects('get')->with(NULL, [ $provider->http->expects('get')->with(null, [
RequestOptions::HEADERS => [ RequestOptions::HEADERS => [
'Authorization' => 'Bearer access_token', 'Authorization' => 'Bearer access_token',
], ],

View File

@ -24,7 +24,7 @@ class TwoFAccountModelTest extends ModelTestCase
public function test_model_configuration() public function test_model_configuration()
{ {
$this->runConfigurationAssertions( $this->runConfigurationAssertions(
new TwoFAccount(), new TwoFAccount,
[], [],
[], [],
['*'], ['*'],
@ -138,7 +138,7 @@ class TwoFAccountModelTest extends ModelTestCase
#[Test] #[Test]
public function test_user_relation() public function test_user_relation()
{ {
$model = new TwoFAccount(); $model = new TwoFAccount;
$relation = $model->user(); $relation = $model->user();
$this->assertInstanceOf(BelongsTo::class, $relation); $this->assertInstanceOf(BelongsTo::class, $relation);

View File

@ -18,7 +18,7 @@ class UserModelTest extends ModelTestCase
#[Test] #[Test]
public function test_model_configuration() public function test_model_configuration()
{ {
$this->runConfigurationAssertions(new User(), $this->runConfigurationAssertions(new User,
['name', 'email', 'password', 'oauth_id', 'oauth_provider'], ['name', 'email', 'password', 'oauth_id', 'oauth_provider'],
['password', 'remember_token'], ['password', 'remember_token'],
['*'], ['*'],
@ -47,17 +47,17 @@ class UserModelTest extends ModelTestCase
#[Test] #[Test]
public function test_twofaccounts_relation() public function test_twofaccounts_relation()
{ {
$user = new User(); $user = new User;
$accounts = $user->twofaccounts(); $accounts = $user->twofaccounts();
$this->assertHasManyRelation($accounts, $user, new TwoFAccount()); $this->assertHasManyRelation($accounts, $user, new TwoFAccount);
} }
#[Test] #[Test]
public function test_groups_relation() public function test_groups_relation()
{ {
$user = new User(); $user = new User;
$groups = $user->groups(); $groups = $user->groups();
$this->assertHasManyRelation($groups, $user, new Group()); $this->assertHasManyRelation($groups, $user, new Group);
} }
#[Test] #[Test]