mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-25 09:44:04 +01:00
Fix tests (see 533b913
)
This commit is contained in:
parent
9f453582a3
commit
3413d31a3c
@ -83,7 +83,7 @@ public function test_allPreferences_returns_preferences_with_default_values()
|
||||
public function test_allPreferences_returns_preferences_with_user_values()
|
||||
{
|
||||
$userPrefs = [
|
||||
'showTokenAsDot' => true,
|
||||
'showOtpAsDot' => true,
|
||||
'closeOtpOnCopy' => true,
|
||||
'copyOtpOnDisplay' => true,
|
||||
'useBasicQrcodeReader' => true,
|
||||
@ -103,7 +103,7 @@ public function test_allPreferences_returns_preferences_with_user_values()
|
||||
'lang' => 'fr',
|
||||
];
|
||||
|
||||
$this->user['preferences->showTokenAsDot'] = $userPrefs['showTokenAsDot'];
|
||||
$this->user['preferences->showOtpAsDot'] = $userPrefs['showOtpAsDot'];
|
||||
$this->user['preferences->closeOtpOnCopy'] = $userPrefs['closeOtpOnCopy'];
|
||||
$this->user['preferences->copyOtpOnDisplay'] = $userPrefs['copyOtpOnDisplay'];
|
||||
$this->user['preferences->useBasicQrcodeReader'] = $userPrefs['useBasicQrcodeReader'];
|
||||
@ -146,11 +146,11 @@ public function test_showPreference_returns_preference_with_default_value()
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('GET', '/api/v1/user/preferences/showTokenAsDot')
|
||||
->json('GET', '/api/v1/user/preferences/showOtpAsDot')
|
||||
->assertOk()
|
||||
->assertExactJson([
|
||||
'key' => 'showTokenAsDot',
|
||||
'value' => config('2fauth.preferences.showTokenAsDot'),
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => config('2fauth.preferences.showOtpAsDot'),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -159,15 +159,15 @@ public function test_showPreference_returns_preference_with_default_value()
|
||||
*/
|
||||
public function test_showPreference_returns_preference_with_custom_value()
|
||||
{
|
||||
$showTokenAsDot = ! config('2fauth.preferences.showTokenAsDot');
|
||||
$this->user['preferences->showTokenAsDot'] = $showTokenAsDot;
|
||||
$showOtpAsDot = ! config('2fauth.preferences.showOtpAsDot');
|
||||
$this->user['preferences->showOtpAsDot'] = $showOtpAsDot;
|
||||
$this->user->save();
|
||||
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('GET', '/api/v1/user/preferences/showTokenAsDot')
|
||||
->json('GET', '/api/v1/user/preferences/showOtpAsDot')
|
||||
->assertJsonFragment([
|
||||
'key' => 'showTokenAsDot',
|
||||
'value' => $showTokenAsDot,
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => $showOtpAsDot,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -191,17 +191,17 @@ public function test_setPreference_returns_updated_preference()
|
||||
*/
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
$showTokenAsDot = ! config('2fauth.preferences.showTokenAsDot');
|
||||
$showOtpAsDot = ! config('2fauth.preferences.showOtpAsDot');
|
||||
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('PUT', '/api/v1/user/preferences/showTokenAsDot', [
|
||||
'key' => 'showTokenAsDot',
|
||||
'value' => $showTokenAsDot,
|
||||
->json('PUT', '/api/v1/user/preferences/showOtpAsDot', [
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => $showOtpAsDot,
|
||||
])
|
||||
->assertCreated()
|
||||
->assertExactJson([
|
||||
'key' => 'showTokenAsDot',
|
||||
'value' => $showTokenAsDot,
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => $showOtpAsDot,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ public function test_setPreference_for_missing_preference_returns_not_found()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('PUT', '/api/v1/user/preferences/unknown', [
|
||||
'key' => 'showTokenAsDot',
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => true,
|
||||
])
|
||||
->assertNotFound();
|
||||
@ -224,8 +224,8 @@ public function test_setPreference_for_missing_preference_returns_not_found()
|
||||
public function test_setPreference_with_invalid_data_returns_validation_error()
|
||||
{
|
||||
$response = $this->actingAs($this->user, 'api-guard')
|
||||
->json('PUT', '/api/v1/user/preferences/showTokenAsDot', [
|
||||
'key' => 'showTokenAsDot',
|
||||
->json('PUT', '/api/v1/user/preferences/showOtpAsDot', [
|
||||
'key' => 'showOtpAsDot',
|
||||
'value' => null,
|
||||
])
|
||||
->assertStatus(422);
|
||||
|
@ -69,7 +69,7 @@ public function test_infos_returns_user_preferences_when_signed_in()
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'user_preferences' => [
|
||||
'showTokenAsDot',
|
||||
'showOtpAsDot',
|
||||
'closeOtpOnCopy',
|
||||
'copyOtpOnDisplay',
|
||||
'useBasicQrcodeReader',
|
||||
|
@ -349,10 +349,10 @@ public function test_del_remove_setting_from_db_and_cache()
|
||||
public function test_isEdited_returns_true()
|
||||
{
|
||||
DB::table('options')->insert(
|
||||
[self::KEY => 'showTokenAsDot', self::VALUE => strval(self::SETTING_VALUE_TRUE_TRANSFORMED)]
|
||||
[self::KEY => 'showOtpAsDot', self::VALUE => strval(self::SETTING_VALUE_TRUE_TRANSFORMED)]
|
||||
);
|
||||
|
||||
$this->assertTrue(Settings::isEdited('showTokenAsDot'));
|
||||
$this->assertTrue(Settings::isEdited('showOtpAsDot'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,9 +360,9 @@ public function test_isEdited_returns_true()
|
||||
*/
|
||||
public function test_isEdited_returns_false()
|
||||
{
|
||||
DB::table('options')->where(self::KEY, 'showTokenAsDot')->delete();
|
||||
DB::table('options')->where(self::KEY, 'showOtpAsDot')->delete();
|
||||
|
||||
$this->assertFalse(Settings::isEdited('showTokenAsDot'));
|
||||
$this->assertFalse(Settings::isEdited('showOtpAsDot'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user