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 @@ public function handle() : void
{
$retentionTime = config('2fauth.config.authLogRetentionTime');
$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)
->orWhere('logout_at', '<', $date)

View File

@ -12,11 +12,11 @@ class CaseInsensitiveEmailExists 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
{
$user = DB::table('users')
->whereRaw('email = ?' . ('sqlite' === config('database.default') ? ' COLLATE NOCASE' : ''), [strtolower($value)])
->first();
->whereRaw('email = ?' . (config('database.default') === 'sqlite' ? ' COLLATE NOCASE' : ''), [strtolower($value)])
->first();
if (! $user) {
$fail('validation.custom.email.exists')->translate();

View File

@ -77,7 +77,8 @@ public function migrate(mixed $migrationPayload) : Collection
/**
* Encode into uppercase Base32
*/
protected function toBase32(string $str) {
protected function toBase32(string $str)
{
return Base32::encodeUpper($str);
}
}

View File

@ -39,16 +39,16 @@ public function test_purgeLog_completes()
*/
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();
$this->artisan('2fauth:purge-log');
$this->assertDatabaseHas('auth_logs', [
'id' => $sixMonthsOldLog->id
'id' => $sixMonthsOldLog->id,
]);
$this->assertDatabaseMissing('auth_logs', [
'id' => $oneYearOldLog->id
'id' => $oneYearOldLog->id,
]);
}
@ -64,7 +64,7 @@ public function test_purgeLog_deletes_records_older_than_retention_time()
$this->artisan('2fauth:purge-log');
$this->assertDatabaseMissing('auth_logs', [
'id' => $log->id
'id' => $log->id,
]);
}
@ -81,7 +81,7 @@ public function test_purgeLog_deletes_logout_only_records_older_than_retention_t
$this->artisan('2fauth:purge-log');
$this->assertDatabaseMissing('auth_logs', [
'id' => $log->id
'id' => $log->id,
]);
}
@ -97,7 +97,7 @@ public function test_purgeLog_does_not_delete_records_younger_than_retention_tim
$this->artisan('2fauth:purge-log');
$this->assertDatabaseHas('auth_logs', [
'id' => $log->id
'id' => $log->id,
]);
}
@ -108,16 +108,16 @@ public function test_purgeLog_does_not_delete_records_younger_than_retention_tim
public function test_purgeLog_with_invalid_config_defaults_to_one_year($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();
$this->artisan('2fauth:purge-log');
$this->assertDatabaseHas('auth_logs', [
'id' => $sixMonthsOldLog->id
'id' => $sixMonthsOldLog->id,
]);
$this->assertDatabaseMissing('auth_logs', [
'id' => $oneYearOldLog->id
'id' => $oneYearOldLog->id,
]);
}
@ -128,15 +128,14 @@ public static function provideInvalidConfig() : array
{
return [
'NULL' => [
null
null,
],
'EMPTY' => [
''
'',
],
'STRING' => [
'ljhkjh'
'ljhkjh',
],
];
}
}

View File

@ -16,7 +16,6 @@
use App\Services\Migrators\TwoFAuthMigrator;
use App\Services\SettingService;
use Illuminate\Support\Facades\Storage;
use Mockery;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
@ -141,7 +140,6 @@ public function setUp() : void
/**
* Clean up the testing environment before the next test.
*
* @return void
*
* @throws \Mockery\Exception\InvalidCountException
*/