mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-14 08:56:39 +02:00
Fix the TwoFAccount Export feature & add related tests
This commit is contained in:
parent
af4400a74d
commit
823acde49d
@ -68,6 +68,8 @@ class TwoFAccountService
|
|||||||
public static function export($ids) : Collection
|
public static function export($ids) : Collection
|
||||||
{
|
{
|
||||||
$ids = Helpers::commaSeparatedToArray($ids);
|
$ids = Helpers::commaSeparatedToArray($ids);
|
||||||
|
$ids = is_array($ids) ? $ids : func_get_args();
|
||||||
|
|
||||||
$twofaccounts = TwoFAccount::whereIn('id', $ids)->get();
|
$twofaccounts = TwoFAccount::whereIn('id', $ids)->get();
|
||||||
|
|
||||||
return $twofaccounts;
|
return $twofaccounts;
|
||||||
|
@ -230,6 +230,41 @@ class TwoFAccountServiceTest extends FeatureTestCase
|
|||||||
$twofaccounts = TwoFAccounts::migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA);
|
$twofaccounts = TwoFAccounts::migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function test_export_single_id_returns_collection()
|
||||||
|
{
|
||||||
|
$twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id);
|
||||||
|
|
||||||
|
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $twofaccounts);
|
||||||
|
$this->assertObjectEquals($this->customTotpTwofaccount, $twofaccounts->first());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function test_export_comma_separated_ids_returns_collection()
|
||||||
|
{
|
||||||
|
$twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id . ',' . $this->customHotpTwofaccount->id);
|
||||||
|
|
||||||
|
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $twofaccounts);
|
||||||
|
$this->assertObjectEquals($this->customTotpTwofaccount, $twofaccounts->first());
|
||||||
|
$this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function test_export_array_of_ids_returns_collection()
|
||||||
|
{
|
||||||
|
$twofaccounts = TwoFAccounts::export([$this->customTotpTwofaccount->id, $this->customHotpTwofaccount->id]);
|
||||||
|
|
||||||
|
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $twofaccounts);
|
||||||
|
$this->assertObjectEquals($this->customTotpTwofaccount, $twofaccounts->first());
|
||||||
|
$this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user