mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-25 17:54:57 +01:00
Complete logs & tests
This commit is contained in:
parent
e0d2786fe5
commit
21d6816151
@ -39,12 +39,15 @@ public static function withdraw($ids) : void
|
|||||||
// whereIn() expects an array
|
// whereIn() expects an array
|
||||||
$ids = is_array($ids) ? $ids : func_get_args();
|
$ids = is_array($ids) ? $ids : func_get_args();
|
||||||
|
|
||||||
TwoFAccount::whereIn('id', $ids)
|
$affectedCount = TwoFAccount::whereIn('id', $ids)
|
||||||
->update(
|
->update(
|
||||||
['group_id' => null]
|
['group_id' => null]
|
||||||
);
|
);
|
||||||
|
|
||||||
Log::info(sprintf('TwoFAccounts IDs #%s withdrawn', implode(',', $ids)));
|
if ($affectedCount) {
|
||||||
|
Log::info(sprintf('TwoFAccounts with IDs #%s withdrawn', implode(',', $ids)));
|
||||||
|
}
|
||||||
|
else Log::info(sprintf('Cannot find TwoFAccounts to withdraw using ids #%s', implode(',', $ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
use App\Models\TwoFAccount;
|
use App\Models\TwoFAccount;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\TwoFAccountService;
|
use App\Services\TwoFAccountService;
|
||||||
|
use Illuminate\Support\Facades\Exceptions;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use Tests\Data\MigrationTestData;
|
use Tests\Data\MigrationTestData;
|
||||||
@ -151,9 +152,21 @@ public function test_withdraw_single_id_deletes_relation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
public function test_withdraw_missing_ids_returns_void()
|
public function test_withdraw_missing_ids_does_not_throw_exception()
|
||||||
{
|
{
|
||||||
$this->assertNull(TwoFAccounts::withdraw(null));
|
Exceptions::fake();
|
||||||
|
Exceptions::assertNothingReported();
|
||||||
|
|
||||||
|
TwoFAccounts::withdraw(9999999);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function test_withdraw_null_id_does_not_throw_exception()
|
||||||
|
{
|
||||||
|
Exceptions::fake();
|
||||||
|
Exceptions::assertNothingReported();
|
||||||
|
|
||||||
|
TwoFAccounts::withdraw(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
|
Loading…
Reference in New Issue
Block a user