From 3413d31a3cc922943df7ba693bead1eeeb52bb76 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 14 Apr 2023 17:54:35 +0200 Subject: [PATCH] Fix tests (see 533b913) --- .../Controllers/Auth/UserControllerTest.php | 38 +++++++++---------- tests/Feature/Http/SystemControllerTest.php | 2 +- tests/Feature/Services/SettingServiceTest.php | 8 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/Api/v1/Controllers/Auth/UserControllerTest.php b/tests/Api/v1/Controllers/Auth/UserControllerTest.php index 39863fb8..62875657 100644 --- a/tests/Api/v1/Controllers/Auth/UserControllerTest.php +++ b/tests/Api/v1/Controllers/Auth/UserControllerTest.php @@ -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); diff --git a/tests/Feature/Http/SystemControllerTest.php b/tests/Feature/Http/SystemControllerTest.php index a15b14d6..36038b05 100644 --- a/tests/Feature/Http/SystemControllerTest.php +++ b/tests/Feature/Http/SystemControllerTest.php @@ -69,7 +69,7 @@ public function test_infos_returns_user_preferences_when_signed_in() ->assertOk() ->assertJsonStructure([ 'user_preferences' => [ - 'showTokenAsDot', + 'showOtpAsDot', 'closeOtpOnCopy', 'copyOtpOnDisplay', 'useBasicQrcodeReader', diff --git a/tests/Feature/Services/SettingServiceTest.php b/tests/Feature/Services/SettingServiceTest.php index adf16fa7..7aebdefb 100644 --- a/tests/Feature/Services/SettingServiceTest.php +++ b/tests/Feature/Services/SettingServiceTest.php @@ -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')); } /**