Fix pint issues

This commit is contained in:
Bubka 2024-05-29 11:53:41 +02:00
parent 7e52dcd7da
commit bc090e2d4d
6 changed files with 20 additions and 22 deletions

View File

@ -51,7 +51,7 @@ class PurgeAuthLog extends Command
{ {
$retentionTime = config('2fauth.config.authLogRetentionTime'); $retentionTime = config('2fauth.config.authLogRetentionTime');
$retentionTime = is_numeric($retentionTime) ? (int) $retentionTime : 365; $retentionTime = is_numeric($retentionTime) ? (int) $retentionTime : 365;
$date = now()->subDays($retentionTime)->format('Y-m-d H:i:s'); $date = now()->subDays($retentionTime)->format('Y-m-d H:i:s');
AuthLog::where('login_at', '<', $date) AuthLog::where('login_at', '<', $date)
->orWhere('logout_at', '<', $date) ->orWhere('logout_at', '<', $date)

View File

@ -12,11 +12,11 @@ class CaseInsensitiveEmailExists implements ValidationRule
/** /**
* Run the validation rule. * Run the validation rule.
*/ */
public function validate(string $attribute, mixed $value, Closure $fail): void public function validate(string $attribute, mixed $value, Closure $fail) : void
{ {
$user = DB::table('users') $user = DB::table('users')
->whereRaw('email = ?' . ('sqlite' === config('database.default') ? ' COLLATE NOCASE' : ''), [strtolower($value)]) ->whereRaw('email = ?' . (config('database.default') === 'sqlite' ? ' COLLATE NOCASE' : ''), [strtolower($value)])
->first(); ->first();
if (! $user) { if (! $user) {
$fail('validation.custom.email.exists')->translate(); $fail('validation.custom.email.exists')->translate();

View File

@ -77,7 +77,8 @@ class GoogleAuthMigrator extends Migrator
/** /**
* Encode into uppercase Base32 * Encode into uppercase Base32
*/ */
protected function toBase32(string $str) { protected function toBase32(string $str)
{
return Base32::encodeUpper($str); return Base32::encodeUpper($str);
} }
} }

View File

@ -39,16 +39,16 @@ class PurgeLogTest extends FeatureTestCase
*/ */
public function test_purgeLog_defaults_to_one_year() public function test_purgeLog_defaults_to_one_year()
{ {
$oneYearOldLog = AuthLog::factory()->daysAgo(366)->for($this->user, 'authenticatable')->create(); $oneYearOldLog = AuthLog::factory()->daysAgo(366)->for($this->user, 'authenticatable')->create();
$sixMonthsOldLog = AuthLog::factory()->daysAgo(364)->for($this->user, 'authenticatable')->create(); $sixMonthsOldLog = AuthLog::factory()->daysAgo(364)->for($this->user, 'authenticatable')->create();
$this->artisan('2fauth:purge-log'); $this->artisan('2fauth:purge-log');
$this->assertDatabaseHas('auth_logs', [ $this->assertDatabaseHas('auth_logs', [
'id' => $sixMonthsOldLog->id 'id' => $sixMonthsOldLog->id,
]); ]);
$this->assertDatabaseMissing('auth_logs', [ $this->assertDatabaseMissing('auth_logs', [
'id' => $oneYearOldLog->id 'id' => $oneYearOldLog->id,
]); ]);
} }
@ -64,7 +64,7 @@ class PurgeLogTest extends FeatureTestCase
$this->artisan('2fauth:purge-log'); $this->artisan('2fauth:purge-log');
$this->assertDatabaseMissing('auth_logs', [ $this->assertDatabaseMissing('auth_logs', [
'id' => $log->id 'id' => $log->id,
]); ]);
} }
@ -81,7 +81,7 @@ class PurgeLogTest extends FeatureTestCase
$this->artisan('2fauth:purge-log'); $this->artisan('2fauth:purge-log');
$this->assertDatabaseMissing('auth_logs', [ $this->assertDatabaseMissing('auth_logs', [
'id' => $log->id 'id' => $log->id,
]); ]);
} }
@ -97,7 +97,7 @@ class PurgeLogTest extends FeatureTestCase
$this->artisan('2fauth:purge-log'); $this->artisan('2fauth:purge-log');
$this->assertDatabaseHas('auth_logs', [ $this->assertDatabaseHas('auth_logs', [
'id' => $log->id 'id' => $log->id,
]); ]);
} }
@ -108,16 +108,16 @@ class PurgeLogTest extends FeatureTestCase
public function test_purgeLog_with_invalid_config_defaults_to_one_year($config) public function test_purgeLog_with_invalid_config_defaults_to_one_year($config)
{ {
config(['2fauth.config.authLogRetentionTime' => $config]); config(['2fauth.config.authLogRetentionTime' => $config]);
$oneYearOldLog = AuthLog::factory()->daysAgo(366)->for($this->user, 'authenticatable')->create(); $oneYearOldLog = AuthLog::factory()->daysAgo(366)->for($this->user, 'authenticatable')->create();
$sixMonthsOldLog = AuthLog::factory()->daysAgo(364)->for($this->user, 'authenticatable')->create(); $sixMonthsOldLog = AuthLog::factory()->daysAgo(364)->for($this->user, 'authenticatable')->create();
$this->artisan('2fauth:purge-log'); $this->artisan('2fauth:purge-log');
$this->assertDatabaseHas('auth_logs', [ $this->assertDatabaseHas('auth_logs', [
'id' => $sixMonthsOldLog->id 'id' => $sixMonthsOldLog->id,
]); ]);
$this->assertDatabaseMissing('auth_logs', [ $this->assertDatabaseMissing('auth_logs', [
'id' => $oneYearOldLog->id 'id' => $oneYearOldLog->id,
]); ]);
} }
@ -128,15 +128,14 @@ class PurgeLogTest extends FeatureTestCase
{ {
return [ return [
'NULL' => [ 'NULL' => [
null null,
], ],
'EMPTY' => [ 'EMPTY' => [
'' '',
], ],
'STRING' => [ 'STRING' => [
'ljhkjh' 'ljhkjh',
], ],
]; ];
} }
} }

View File

@ -16,7 +16,6 @@ use App\Services\Migrators\TwoFASMigrator;
use App\Services\Migrators\TwoFAuthMigrator; use App\Services\Migrators\TwoFAuthMigrator;
use App\Services\SettingService; use App\Services\SettingService;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Mockery;
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;
@ -141,7 +140,6 @@ class MigratorTest extends TestCase
/** /**
* Clean up the testing environment before the next test. * Clean up the testing environment before the next test.
* *
* @return void
* *
* @throws \Mockery\Exception\InvalidCountException * @throws \Mockery\Exception\InvalidCountException
*/ */