Apply Pint fixes

This commit is contained in:
Bubka 2023-12-20 16:55:58 +01:00
parent 71840b000a
commit ecd905c36c
36 changed files with 141 additions and 160 deletions

View File

@ -28,7 +28,7 @@ class GroupController extends Controller
Groups::setUser($groups, $request->user());
}
}
// We do not use fluent call all over the call chain to ease tests
$user = $request->user();
$groups = $user->groups()->withCount('twofaccounts')->get();

View File

@ -151,8 +151,8 @@ class TwoFAccountController extends Controller
$orderedIds = $request->user()->twofaccounts->sortBy('order_column')->pluck('id');
return response()->json([
'message' => 'order saved',
'orderedIds' => $orderedIds
'message' => 'order saved',
'orderedIds' => $orderedIds,
], 200);
}

View File

@ -1,19 +1,18 @@
<?php
/**
*
* The MIT License (MIT)
* Copyright (c) 2023 Bubka
* Copyright (c) 2018 Phan An (https://github.com/koel/koel/blob/master/app/Console/Commands/InitCommand.php)
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
@ -26,14 +25,10 @@ namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\Connection;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Database\SQLiteDatabaseDoesNotExistException;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Jackiedo\DotenvEditor\DotenvEditor;
use PDOException;
use Throwable;
class Install extends Command
@ -64,13 +59,11 @@ class Install extends Command
/**
* Create a new command instance.
*
* @param \Jackiedo\DotenvEditor\DotenvEditor $dotenvEditor
* @return void
*/
public function __construct(
protected DotenvEditor $dotenvEditor,
)
{
) {
parent::__construct();
}
@ -115,7 +108,7 @@ class Install extends Command
$this->newLine();
$this->components->error($e->getMessage());
$this->components->info('See the error log at storage/logs/laravel.log for the full stack trace.');
$this->newLine();
$this->line('Fix the error and rerun the \'2fauth:install\' command to complete installation.');
$this->newLine();
@ -201,7 +194,6 @@ class Install extends Command
$this->dotenvEditor->setKey('APP_URL', $appUrl);
}
/**
* Prompt user for valid database credentials and set them to .env file.
*/
@ -232,7 +224,7 @@ class Install extends Command
$config['DB_DATABASE'] = $this->ask('Absolute path to the DB file', $databasePath);
} else {
$defaultName = $this->dotenvEditor->getValue('DB_DATABASE') ?: '2fauth';
$defaultName = $this->dotenvEditor->getValue('DB_DATABASE') ?: '2fauth';
$databaseName = $this->dotenvEditor->getValue('DB_CONNECTION') == 'sqlite'
? '2fauth'
: $defaultName;
@ -250,7 +242,7 @@ class Install extends Command
// Set the config so that the next DB attempt uses refreshed credentials
config([
'database.default' => $config['DB_CONNECTION'],
'database.default' => $config['DB_CONNECTION'],
'database.connections.' . $config['DB_CONNECTION'] . '.database' => $config['DB_DATABASE'],
'database.connections.' . $config['DB_CONNECTION'] . '.host' => $config['DB_HOST'],
'database.connections.' . $config['DB_CONNECTION'] . '.port' => $config['DB_PORT'],
@ -299,7 +291,7 @@ class Install extends Command
}
$this->components->task('Preparing .env file', static function () : void {
if (!file_exists(base_path('.env'))) {
if (! file_exists(base_path('.env'))) {
copy(base_path('.env.example'), base_path('.env'));
}
});
@ -315,7 +307,7 @@ class Install extends Command
$key = config('app.key');
$this->components->task($key ? 'Retrieving app key' : 'Generating app key', function () use (&$key) : void {
if (!$key) {
if (! $key) {
// Generate the key manually to prevent some clashes with `php artisan key:generate`
$key = $this->generateRandomKey();
$this->dotenvEditor->setKey('APP_KEY', $key);

View File

@ -4,7 +4,6 @@ namespace App\Console\Commands\Maintenance;
use App\Models\TwoFAccount;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Schema;
/**
* @codeCoverageIgnore
@ -31,7 +30,7 @@ class FixOrphanAccounts extends Command
* @var bool
*/
protected $hidden = true;
/**
* Create a new command instance.
*
@ -50,12 +49,12 @@ class FixOrphanAccounts extends Command
public function handle()
{
$twofaccounts = TwoFAccount::where('otp_type', '')
->where('secret', '')
->where('algorithm', '')
->where('digits', 0)
->whereNull('period')
->whereNull('counter')
->get();
->where('secret', '')
->where('algorithm', '')
->where('digits', 0)
->whereNull('period')
->whereNull('counter')
->get();
$this->line(sprintf('%d inconsistent accounts found', $twofaccounts->count()));

View File

@ -58,12 +58,12 @@ class FixUnsplittedAccounts extends Command
}
$twofaccounts = TwoFAccount::where('otp_type', '')
->where('secret', '')
->where('algorithm', '')
->where('digits', 0)
->whereNull('period')
->whereNull('counter')
->get();
->where('secret', '')
->where('algorithm', '')
->where('digits', 0)
->whereNull('period')
->whereNull('counter')
->get();
$this->line(sprintf('%d inconsistent accounts found', $twofaccounts->count()));

View File

@ -13,7 +13,7 @@ class WebauthnCredentialBroker extends PasswordBroker
/**
* Send a password reset link to a user.
*/
public function sendResetLink(array $credentials, Closure $callback = null) : string
public function sendResetLink(array $credentials, ?Closure $callback = null) : string
{
/**
* @var \App\Models\User

View File

@ -16,7 +16,6 @@ class Helpers
/**
* Format a string to comply with Base32 format
*
* @param string $str
* @return string The filename
*/
public static function PadToBase32Format(?string $str) : string

View File

@ -15,7 +15,7 @@ class SocialiteController extends Controller
{
/**
* Redirect to the provider's authentication url
*
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Illuminate\Http\RedirectResponse
*/
public function redirect(Request $request, string $driver)
@ -31,7 +31,7 @@ class SocialiteController extends Controller
/**
* Register (if needed) the user and authenticate him
*
*
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
*/
public function callback(Request $request, string $driver)
@ -42,7 +42,7 @@ class SocialiteController extends Controller
return redirect('/error?err=sso_failed');
}
$uniqueName = $socialiteUser->getId() . '@' . $driver;
$uniqueName = $socialiteUser->getId() . '@' . $driver;
$socialiteEmail = $socialiteUser->getEmail() ?? $uniqueName;
$socialiteName = ($socialiteUser->getNickname() ?? $socialiteUser->getName()) . ' (' . $uniqueName . ')';
@ -55,11 +55,9 @@ class SocialiteController extends Controller
if (! $user->exists) {
if (User::where('email', $socialiteEmail)->exists()) {
return redirect('/error?err=sso_email_already_used');
}
else if (User::count() === 0) {
} elseif (User::count() === 0) {
$user->is_admin = true;
}
else if (Settings::get('disableRegistration')) {
} elseif (Settings::get('disableRegistration')) {
return redirect('/error?err=sso_no_register');
}
$user->password = bcrypt(Str::random());

View File

@ -41,7 +41,7 @@ class SinglePageController extends Controller
'openid' => $openidAuth,
'github' => $githubAuth,
],
'subdirectory' => $subdir,
'subdirectory' => $subdir,
])->toJson(),
'defaultPreferences' => $defaultPreferences,
'subdirectory' => $subdir,

View File

@ -55,7 +55,7 @@ class Kernel extends HttpKernel
],
'api.v1' => [
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\KickOutInactiveUser::class,
\App\Http\Middleware\LogUserLastSeen::class,

View File

@ -94,24 +94,24 @@ class Group extends Model
return $this->hasMany(\App\Models\TwoFAccount::class);
}
/**
* Get the user that owns the group.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, \App\Models\Group>
*/
public function user()
{
return $this->belongsTo(\App\Models\User::class);
}
/**
* Get the user that owns the group.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, \App\Models\Group>
*/
public function user()
{
return $this->belongsTo(\App\Models\User::class);
}
/**
* Scope a query to only include orphan (userless) groups.
*
* @param \Illuminate\Database\Eloquent\Builder<User> $query
* @return \Illuminate\Database\Eloquent\Builder<User>
*/
public function scopeOrphans($query)
{
return $query->where('user_id', null);
}
/**
* Scope a query to only include orphan (userless) groups.
*
* @param \Illuminate\Database\Eloquent\Builder<User> $query
* @return \Illuminate\Database\Eloquent\Builder<User>
*/
public function scopeOrphans($query)
{
return $query->where('user_id', null);
}
}

View File

@ -56,7 +56,7 @@ use SteamTotp\SteamTotp;
*/
class TwoFAccount extends Model implements Sortable
{
use SortableTrait, HasFactory;
use HasFactory, SortableTrait;
const TOTP = 'totp';
@ -634,7 +634,7 @@ class TwoFAccount extends Model implements Sortable
* @param string $extension The file extension, without the dot
* @return string|null The filename of the stored icon or null if the operation fails
*/
private function storeFileDataAsIcon($content, $extension) : string|null
private function storeFileDataAsIcon($content, $extension) : ?string
{
$filename = self::getUniqueFilename($extension);
@ -684,7 +684,7 @@ class TwoFAccount extends Model implements Sortable
*
* @return string|null The filename of the stored icon or null if the operation fails
*/
private function storeRemoteImageAsIcon(string $url) : string|null
private function storeRemoteImageAsIcon(string $url) : ?string
{
try {
$path_parts = pathinfo($url);

View File

@ -40,8 +40,8 @@ use Laravel\Passport\HasApiTokens;
*/
class User extends Authenticatable implements WebAuthnAuthenticatable
{
use WebAuthnAuthentication, WebAuthnManageCredentials;
use HasApiTokens, HasFactory, Notifiable;
use WebAuthnAuthentication, WebAuthnManageCredentials;
/**
* The attributes that are mass assignable.
@ -49,7 +49,7 @@ class User extends Authenticatable implements WebAuthnAuthenticatable
* @var string[]
*/
protected $fillable = [
'name', 'email', 'password', 'oauth_id', 'oauth_provider'
'name', 'email', 'password', 'oauth_id', 'oauth_provider',
];
/**

View File

@ -8,9 +8,9 @@ use App\Events\ScanForNewReleaseCalled;
use App\Events\TwoFAccountDeleted;
use App\Listeners\CleanIconStorage;
use App\Listeners\DissociateTwofaccountFromGroup;
use App\Listeners\RegisterOpenId;
use App\Listeners\ReleaseRadar;
use App\Listeners\ResetUsersPreference;
use App\Listeners\RegisterOpenId;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

View File

@ -14,8 +14,6 @@ class MigrationServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register() : void
{

View File

@ -3,10 +3,8 @@
namespace App\Providers\Socialite;
use GuzzleHttp\RequestOptions;
use InvalidArgumentException;
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
use SocialiteProviders\Manager\OAuth2\User;
use SocialiteProviders\Manager\SocialiteWasCalled;
class OpenId extends AbstractProvider
{
@ -48,7 +46,7 @@ class OpenId extends AbstractProvider
{
$response = $this->getHttpClient()->get($this->getConfig('userinfo_url'), [
RequestOptions::HEADERS => [
'Authorization' => 'Bearer '.$token,
'Authorization' => 'Bearer ' . $token,
],
]);

View File

@ -12,7 +12,7 @@ class IsBase32Encoded implements ValidationRule
/**
* Run the validation rule.
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
public function validate(string $attribute, mixed $value, Closure $fail) : void
{
try {
$secret = Base32::decodeUpper(Helpers::PadToBase32Format($value));

View File

@ -19,7 +19,7 @@ class GroupService
*
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public static function assign($ids, User $user, Group $group = null) : void
public static function assign($ids, User $user, ?Group $group = null) : void
{
if (! $group) {
$group = self::defaultGroup($user);
@ -62,9 +62,8 @@ class GroupService
/**
* Set owner of given groups
*
*
* @param Collection<int, Group> $groups
* @param \App\Models\User $user
*/
public static function setUser(Collection $groups, User $user) : void
{

View File

@ -41,8 +41,8 @@ class ReleaseRadarService
if ($latestRelease) {
$latestReleaseData = json_decode($latestRelease);
$githubVersion = Helpers::cleanVersionNumber($latestReleaseData->tag_name);
$installedVersion = Helpers::cleanVersionNumber(config('2fauth.version'));
$githubVersion = Helpers::cleanVersionNumber($latestReleaseData->tag_name);
$installedVersion = Helpers::cleanVersionNumber(config('2fauth.version'));
if ($githubVersion && $installedVersion) {
if (version_compare($githubVersion, $installedVersion) > 0 && $latestReleaseData->prerelease == false && $latestReleaseData->draft == false) {
@ -63,7 +63,7 @@ class ReleaseRadarService
/**
* Fetch releases on Github
*/
protected static function getLatestReleaseData() : string|null
protected static function getLatestReleaseData() : ?string
{
$url = config('2fauth.latestReleaseUrl');

View File

@ -215,6 +215,7 @@ class SettingService
$item->secret = $encrypted ? Crypt::encryptString($item->secret) : Crypt::decryptString($item->secret);
} catch (Exception $ex) {
$success = false;
// Exit the each iteration
return false;
}

View File

@ -40,9 +40,9 @@ class TwoFAccountService
$ids = is_array($ids) ? $ids : func_get_args();
TwoFAccount::whereIn('id', $ids)
->update(
['group_id' => null]
);
->update(
['group_id' => null]
);
Log::info(sprintf('TwoFAccounts IDs #%s withdrawn', implode(',', $ids)));
}
@ -96,9 +96,8 @@ class TwoFAccountService
/**
* Set owner of given twofaccounts
*
*
* @param \Illuminate\Support\Collection<int, TwoFAccount> $twofaccounts
* @param \App\Models\User $user
*/
public static function setUser(Collection $twofaccounts, User $user) : void
{

View File

@ -44,10 +44,10 @@ class UserControllerTest extends FeatureTestCase
->json('GET', '/api/v1/user')
->assertOk()
->assertJsonFragment([
'name' => $this->user->name,
'id' => $this->user->id,
'email' => $this->user->email,
'is_admin' => $this->user->is_admin,
'name' => $this->user->name,
'id' => $this->user->id,
'email' => $this->user->email,
'is_admin' => $this->user->is_admin,
])
->assertJsonStructure([
'preferences',

View File

@ -444,7 +444,7 @@ class GroupControllerTest extends FeatureTestCase
public function test_destroy_group_of_another_user_is_forbidden()
{
$response = $this->actingAs($this->anotherUser, 'api-guard')
->json('DELETE', '/api/v1/groups/' . $this->userGroupA->id)
->json('DELETE', '/api/v1/groups/' . $this->userGroupA->id)
->assertForbidden()
->assertJsonStructure([
'message',

View File

@ -18,11 +18,11 @@ use App\Providers\TwoFAuthServiceProvider;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\Classes\LocalFile;
use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData;
use Tests\FeatureTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
/**
* TwoFAccountControllerTest test class
@ -1016,7 +1016,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
public function test_export_twofaccount_of_another_user_is_forbidden()
{
$response = $this->actingAs($this->user, 'api-guard')
->json('GET', '/api/v1/twofaccounts/export?ids=' . $this->twofaccountC->id)
->json('GET', '/api/v1/twofaccounts/export?ids=' . $this->twofaccountC->id)
->assertForbidden()
->assertJsonStructure([
'message',
@ -1296,7 +1296,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
public function test_destroy_twofaccount_of_another_user_is_forbidden()
{
$response = $this->actingAs($this->user, 'api-guard')
->json('DELETE', '/api/v1/twofaccounts/' . $this->twofaccountC->id)
->json('DELETE', '/api/v1/twofaccounts/' . $this->twofaccountC->id)
->assertForbidden()
->assertJsonStructure([
'message',
@ -1346,7 +1346,7 @@ class TwoFAccountControllerTest extends FeatureTestCase
->implode(',');
$response = $this->actingAs($this->user, 'api-guard')
->json('DELETE', '/api/v1/twofaccounts?ids=' . $ids)
->json('DELETE', '/api/v1/twofaccounts?ids=' . $ids)
->assertForbidden()
->assertJsonStructure([
'message',

View File

@ -13,8 +13,8 @@ class ResetDemoTest extends FeatureTestCase
public function test_reset_demo_without_demo_mode_succeeded()
{
$this->artisan('2fauth:reset-demo')
->expectsOutput('2fauth:reset-demo can only run when isDemoApp option is On')
->assertSuccessful();
->expectsOutput('2fauth:reset-demo can only run when isDemoApp option is On')
->assertSuccessful();
}
/**
@ -25,9 +25,9 @@ class ResetDemoTest extends FeatureTestCase
Config::set('2fauth.config.isDemoApp', true);
$this->artisan('2fauth:reset-demo')
->expectsOutput('This will reset the app in order to run a clean and fresh demo.')
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'demo')
->assertSuccessful();
->expectsOutput('This will reset the app in order to run a clean and fresh demo.')
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'demo')
->assertSuccessful();
$this->assertDatabaseCount('twofaccounts', 9);
@ -140,9 +140,9 @@ class ResetDemoTest extends FeatureTestCase
Config::set('2fauth.config.isDemoApp', true);
$this->artisan('2fauth:reset-demo')
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null')
->expectsOutput('Bad confirmation word, nothing appened')
->assertSuccessful();
->expectsQuestion('To prevent any mistake please type the word "demo" to go on', 'null')
->expectsOutput('Bad confirmation word, nothing appened')
->assertSuccessful();
}
/**

View File

@ -13,8 +13,8 @@ class ResetTestingTest extends FeatureTestCase
public function test_reset_testing_without_testing_mode_succeeded()
{
$this->artisan('2fauth:reset-testing')
->expectsOutput('2fauth:reset-testing can only run when isTestingApp option is On')
->assertSuccessful();
->expectsOutput('2fauth:reset-testing can only run when isTestingApp option is On')
->assertSuccessful();
}
/**
@ -25,9 +25,9 @@ class ResetTestingTest extends FeatureTestCase
Config::set('2fauth.config.isTestingApp', true);
$this->artisan('2fauth:reset-testing')
->expectsOutput('This will reset the app in order to run a clean and fresh testing app.')
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'testing')
->assertSuccessful();
->expectsOutput('This will reset the app in order to run a clean and fresh testing app.')
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'testing')
->assertSuccessful();
$this->assertDatabaseCount('twofaccounts', 9);
@ -140,9 +140,9 @@ class ResetTestingTest extends FeatureTestCase
Config::set('2fauth.config.isTestingApp', true);
$this->artisan('2fauth:reset-testing')
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'null')
->expectsOutput('Bad confirmation word, nothing appened')
->assertSuccessful();
->expectsQuestion('To prevent any mistake please type the word "testing" to go on', 'null')
->expectsOutput('Bad confirmation word, nothing appened')
->assertSuccessful();
}
/**
@ -153,6 +153,6 @@ class ResetTestingTest extends FeatureTestCase
Config::set('2fauth.config.isTestingApp', true);
$this->artisan('2fauth:reset-testing --no-confirm')
->assertSuccessful();
->assertSuccessful();
}
}

View File

@ -163,7 +163,7 @@ class LoginTest extends FeatureTestCase
->assertUnauthorized();
$this->json('POST', '/user/login', $post)
->assertStatus(429);
->assertStatus(429);
}
/**

View File

@ -145,6 +145,6 @@ class RegisterControllerTest extends FeatureTestCase
'password' => self::PASSWORD,
'password_confirmation' => self::PASSWORD,
])
->assertStatus(403);
->assertStatus(403);
}
}

View File

@ -53,14 +53,13 @@ class SocialiteControllerTest extends FeatureTestCase
'oauth_provider' => self::USER_OAUTH_PROVIDER,
]);
$this->socialiteUser = new \Laravel\Socialite\Two\User;
$this->socialiteUser->id = self::USER_OAUTH_ID;
$this->socialiteUser->name = self::USER_NAME;
$this->socialiteUser->email = self::USER_EMAIL;
$this->socialiteUser = new \Laravel\Socialite\Two\User;
$this->socialiteUser->id = self::USER_OAUTH_ID;
$this->socialiteUser->name = self::USER_NAME;
$this->socialiteUser->email = self::USER_EMAIL;
$this->socialiteUser->nickname = self::USER_NICKNAME;
}
/**
* @test
*/
@ -116,9 +115,9 @@ class SocialiteControllerTest extends FeatureTestCase
*/
public function test_callback_updates_user_informations()
{
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
$socialiteUpdatedUser->id = self::USER_OAUTH_ID;
$socialiteUpdatedUser->email = 'new_email';
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
$socialiteUpdatedUser->id = self::USER_OAUTH_ID;
$socialiteUpdatedUser->email = 'new_email';
$socialiteUpdatedUser->nickname = 'new_nickname';
Socialite::shouldReceive('driver->user')
@ -138,9 +137,9 @@ class SocialiteControllerTest extends FeatureTestCase
*/
public function test_callback_updates_username_with_fallback_value()
{
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
$socialiteUpdatedUser->id = self::USER_OAUTH_ID;
$socialiteUpdatedUser->name = 'new_name';
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
$socialiteUpdatedUser->id = self::USER_OAUTH_ID;
$socialiteUpdatedUser->name = 'new_name';
$socialiteUpdatedUser->email = 'new_email';
Socialite::shouldReceive('driver->user')
@ -160,9 +159,9 @@ class SocialiteControllerTest extends FeatureTestCase
*/
public function test_callback_registers_new_user()
{
$newSocialiteUser = new \Laravel\Socialite\Two\User;
$newSocialiteUser->id = 'new_id';
$newSocialiteUser->name = 'jane';
$newSocialiteUser = new \Laravel\Socialite\Two\User;
$newSocialiteUser->id = 'new_id';
$newSocialiteUser->name = 'jane';
$newSocialiteUser->email = 'jane@provider.com';
Socialite::shouldReceive('driver->user')
@ -183,10 +182,10 @@ class SocialiteControllerTest extends FeatureTestCase
*/
public function test_callback_registers_new_user_with_existing_name()
{
$socialiteUserWithSameName = new \Laravel\Socialite\Two\User;
$socialiteUserWithSameName->id = 'socialiteUserWithSameNameId';
$socialiteUserWithSameName->name = self::USER_NAME;
$socialiteUserWithSameName->email = 'socialiteuserwithsamename@example.com';
$socialiteUserWithSameName = new \Laravel\Socialite\Two\User;
$socialiteUserWithSameName->id = 'socialiteUserWithSameNameId';
$socialiteUserWithSameName->name = self::USER_NAME;
$socialiteUserWithSameName->email = 'socialiteuserwithsamename@example.com';
$socialiteUserWithSameName->nickname = self::USER_NICKNAME;
Socialite::shouldReceive('driver->user')
@ -233,10 +232,10 @@ class SocialiteControllerTest extends FeatureTestCase
'password' => 'password',
]);
$socialiteUserWithSameEmail = new \Laravel\Socialite\Two\User;
$socialiteUserWithSameEmail->id = '666';
$socialiteUserWithSameEmail->name = 'socialiteUserWithSameEmail';
$socialiteUserWithSameEmail->email = 'other@example.com';
$socialiteUserWithSameEmail = new \Laravel\Socialite\Two\User;
$socialiteUserWithSameEmail->id = '666';
$socialiteUserWithSameEmail->name = 'socialiteUserWithSameEmail';
$socialiteUserWithSameEmail->email = 'other@example.com';
$socialiteUserWithSameEmail->nickname = self::USER_NICKNAME;
Socialite::shouldReceive('driver->user')
@ -258,9 +257,9 @@ class SocialiteControllerTest extends FeatureTestCase
{
Settings::set('disableRegistration', true);
$newSocialiteUser = new \Laravel\Socialite\Two\User;
$newSocialiteUser->id = 'rejected_id';
$newSocialiteUser->name = 'jane';
$newSocialiteUser = new \Laravel\Socialite\Two\User;
$newSocialiteUser->id = 'rejected_id';
$newSocialiteUser->name = 'jane';
$newSocialiteUser->email = 'jane@provider.com';
Socialite::shouldReceive('driver->user')
@ -278,9 +277,9 @@ class SocialiteControllerTest extends FeatureTestCase
{
Settings::set('disableRegistration', true);
$newSocialiteUser = new \Laravel\Socialite\Two\User;
$newSocialiteUser->id = 'rejected_id';
$newSocialiteUser->name = 'jane';
$newSocialiteUser = new \Laravel\Socialite\Two\User;
$newSocialiteUser->id = 'rejected_id';
$newSocialiteUser->name = 'jane';
$newSocialiteUser->email = 'jane@provider.com';
Socialite::shouldReceive('driver->user')
@ -293,5 +292,4 @@ class SocialiteControllerTest extends FeatureTestCase
'oauth_provider' => self::USER_OAUTH_PROVIDER,
]);
}
}

View File

@ -316,7 +316,7 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
->assertUnauthorized();
$this->json('POST', '/webauthn/login', self::ASSERTION_RESPONSE_INVALID)
->assertStatus(429);
->assertStatus(429);
}
/**

View File

@ -24,8 +24,8 @@ class UserDeleteRequestTest extends FeatureTestCase
public function test_user_is_authorized()
{
Auth::shouldReceive('check')
->once()
->andReturn(true);
->once()
->andReturn(true);
$request = new UserDeleteRequest();

View File

@ -24,8 +24,8 @@ class UserPatchPwdRequestTest extends TestCase
public function test_user_is_authorized()
{
Auth::shouldReceive('check')
->once()
->andReturn(true);
->once()
->andReturn(true);
$request = new UserPatchPwdRequest();

View File

@ -26,8 +26,8 @@ class UserUpdateRequestTest extends FeatureTestCase
public function test_user_is_authorized()
{
Auth::shouldReceive('check')
->once()
->andReturn(true);
->once()
->andReturn(true);
$request = new UserUpdateRequest();

View File

@ -24,8 +24,8 @@ class WebauthnRenameRequestTest extends TestCase
public function test_user_is_authorized()
{
Auth::shouldReceive('check')
->once()
->andReturn(true);
->once()
->andReturn(true);
$request = new WebauthnRenameRequest();

View File

@ -373,7 +373,7 @@ class SettingServiceTest extends FeatureTestCase
public function test_cache_is_requested_at_instanciation()
{
Cache::shouldReceive('remember')
->andReturn(collect([]));
->andReturn(collect([]));
$settingService = new SettingService();
@ -386,7 +386,7 @@ class SettingServiceTest extends FeatureTestCase
public function test_cache_is_updated_when_setting_is_set()
{
Cache::shouldReceive('remember', 'put')
->andReturn(collect([]), true);
->andReturn(collect([]), true);
$settingService = new SettingService();
$settingService->set(self::SETTING_NAME, self::SETTING_VALUE_STRING);
@ -400,7 +400,7 @@ class SettingServiceTest extends FeatureTestCase
public function test_cache_is_updated_when_setting_is_deleted()
{
Cache::shouldReceive('remember', 'put')
->andReturn(collect([]), true);
->andReturn(collect([]), true);
$settingService = new SettingService();
$settingService->delete(self::SETTING_NAME);

View File

@ -79,7 +79,7 @@ abstract class ModelTestCase extends TestCase
* - `getForeignKey()`: any `HasOneOrMany` or `BelongsTo` relation, but key type differs (see documentaiton).
* - `getQualifiedParentKeyName()`: in case of `HasOneOrMany` relation, there is no `getLocalKey()` method, so this one should be asserted.
*/
protected function assertHasManyRelation($relation, Model $model, Model $related, $key = null, $parent = null, \Closure $queryCheck = null)
protected function assertHasManyRelation($relation, Model $model, Model $related, $key = null, $parent = null, ?\Closure $queryCheck = null)
{
$this->assertInstanceOf(HasMany::class, $relation);
@ -111,7 +111,7 @@ abstract class ModelTestCase extends TestCase
* - `getForeignKey()`: any `HasOneOrMany` or `BelongsTo` relation, but key type differs (see documentaiton).
* - `getOwnerKey()`: `BelongsTo` relation and its extendings.
*/
protected function assertBelongsToRelation($relation, Model $model, Model $related, $key, $owner = null, \Closure $queryCheck = null)
protected function assertBelongsToRelation($relation, Model $model, Model $related, $key, $owner = null, ?\Closure $queryCheck = null)
{
$this->assertInstanceOf(BelongsTo::class, $relation);