Replace DocBlocks tests markup with phpunit v11 attributes

This commit is contained in:
Bubka 2024-06-26 14:29:13 +02:00
parent cced8dbaff
commit 1a752d1243
78 changed files with 624 additions and 1681 deletions

View File

@ -6,6 +6,7 @@
use App\Api\v1\Resources\UserResource; use App\Api\v1\Resources\UserResource;
use App\Models\User; use App\Models\User;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -25,9 +26,6 @@ class UserControllerTest extends FeatureTestCase
'value', 'value',
]; ];
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -35,9 +33,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_show_existing_user_when_authenticated_returns_success() public function test_show_existing_user_when_authenticated_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -54,9 +50,7 @@ public function test_show_existing_user_when_authenticated_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_allPreferences_returns_consistent_json_structure() public function test_allPreferences_returns_consistent_json_structure()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -67,9 +61,7 @@ public function test_allPreferences_returns_consistent_json_structure()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_allPreferences_returns_preferences_with_default_values() public function test_allPreferences_returns_preferences_with_default_values()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -84,9 +76,7 @@ public function test_allPreferences_returns_preferences_with_default_values()
} }
} }
/** #[Test]
* @test
*/
public function test_allPreferences_returns_preferences_with_user_values() public function test_allPreferences_returns_preferences_with_user_values()
{ {
$userPrefs = []; $userPrefs = [];
@ -117,9 +107,7 @@ public function test_allPreferences_returns_preferences_with_user_values()
} }
} }
/** #[Test]
* @test
*/
public function test_showPreference_returns_preference_with_default_value() public function test_showPreference_returns_preference_with_default_value()
{ {
/** /**
@ -136,9 +124,7 @@ public function test_showPreference_returns_preference_with_default_value()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_showPreference_returns_preference_with_custom_value() public function test_showPreference_returns_preference_with_custom_value()
{ {
$showOtpAsDot = ! config('2fauth.preferences.showOtpAsDot'); $showOtpAsDot = ! config('2fauth.preferences.showOtpAsDot');
@ -153,9 +139,7 @@ public function test_showPreference_returns_preference_with_custom_value()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_showPreference_for_missing_preference_returns_not_found() public function test_showPreference_for_missing_preference_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -163,9 +147,7 @@ public function test_showPreference_for_missing_preference_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_setPreference_returns_updated_preference() public function test_setPreference_returns_updated_preference()
{ {
/** /**
@ -187,9 +169,7 @@ public function test_setPreference_returns_updated_preference()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_setPreference_for_missing_preference_returns_not_found() public function test_setPreference_for_missing_preference_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -200,9 +180,7 @@ public function test_setPreference_for_missing_preference_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_setPreference_with_invalid_data_returns_validation_error() public function test_setPreference_with_invalid_data_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')

View File

@ -10,6 +10,7 @@
use App\Models\User; use App\Models\User;
use App\Policies\GroupPolicy; use App\Policies\GroupPolicy;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
#[CoversClass(GroupController::class)] #[CoversClass(GroupController::class)]
@ -50,9 +51,6 @@ class GroupControllerTest extends FeatureTestCase
private const NEW_GROUP_NAME = 'MyNewGroup'; private const NEW_GROUP_NAME = 'MyNewGroup';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -80,9 +78,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_index_returns_user_groups_only_with_pseudo_group() public function test_index_returns_user_groups_only_with_pseudo_group()
{ {
$this->actingAs($this->user, 'api-guard') $this->actingAs($this->user, 'api-guard')
@ -107,9 +103,7 @@ public function test_index_returns_user_groups_only_with_pseudo_group()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_returns_created_group_resource() public function test_store_returns_created_group_resource()
{ {
$this->actingAs($this->user, 'api-guard') $this->actingAs($this->user, 'api-guard')
@ -128,9 +122,7 @@ public function test_store_returns_created_group_resource()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_invalid_data_returns_validation_error() public function test_store_invalid_data_returns_validation_error()
{ {
$this->actingAs($this->user, 'api-guard') $this->actingAs($this->user, 'api-guard')
@ -140,9 +132,7 @@ public function test_store_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_show_returns_group_resource() public function test_show_returns_group_resource()
{ {
$group = Group::factory()->for($this->user)->create([ $group = Group::factory()->for($this->user)->create([
@ -158,9 +148,7 @@ public function test_show_returns_group_resource()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_missing_group_returns_not_found() public function test_show_missing_group_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -171,9 +159,7 @@ public function test_show_missing_group_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_group_of_another_user_is_forbidden() public function test_show_group_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->anotherUser, 'api-guard') $response = $this->actingAs($this->anotherUser, 'api-guard')
@ -184,9 +170,7 @@ public function test_show_group_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_returns_updated_group_resource() public function test_update_returns_updated_group_resource()
{ {
$group = Group::factory()->for($this->user)->create(); $group = Group::factory()->for($this->user)->create();
@ -202,9 +186,7 @@ public function test_update_returns_updated_group_resource()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_missing_group_returns_not_found() public function test_update_missing_group_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -217,9 +199,7 @@ public function test_update_missing_group_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_with_invalid_data_returns_validation_error() public function test_update_with_invalid_data_returns_validation_error()
{ {
$group = Group::factory()->for($this->user)->create(); $group = Group::factory()->for($this->user)->create();
@ -231,9 +211,7 @@ public function test_update_with_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_update_group_of_another_user_is_forbidden() public function test_update_group_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->anotherUser, 'api-guard') $response = $this->actingAs($this->anotherUser, 'api-guard')
@ -246,9 +224,7 @@ public function test_update_group_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_accounts_returns_updated_group_resource() public function test_assign_accounts_returns_updated_group_resource()
{ {
$group = Group::factory()->for($this->user)->create(); $group = Group::factory()->for($this->user)->create();
@ -266,9 +242,7 @@ public function test_assign_accounts_returns_updated_group_resource()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_accounts_to_missing_group_returns_not_found() public function test_assign_accounts_to_missing_group_returns_not_found()
{ {
$accounts = TwoFAccount::factory()->count(2)->for($this->user)->create(); $accounts = TwoFAccount::factory()->count(2)->for($this->user)->create();
@ -283,9 +257,7 @@ public function test_assign_accounts_to_missing_group_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_invalid_accounts_returns_validation_error() public function test_assign_invalid_accounts_returns_validation_error()
{ {
$group = Group::factory()->for($this->user)->create(); $group = Group::factory()->for($this->user)->create();
@ -298,9 +270,7 @@ public function test_assign_invalid_accounts_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_assign_to_group_of_another_user_is_forbidden() public function test_assign_to_group_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->anotherUser, 'api-guard') $response = $this->actingAs($this->anotherUser, 'api-guard')
@ -313,9 +283,7 @@ public function test_assign_to_group_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_accounts_of_another_user_is_forbidden() public function test_assign_accounts_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -328,9 +296,7 @@ public function test_assign_accounts_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_accounts_returns_twofaccounts_collection() public function test_accounts_returns_twofaccounts_collection()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -358,9 +324,7 @@ public function test_accounts_returns_twofaccounts_collection()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_accounts_returns_twofaccounts_collection_with_secret() public function test_accounts_returns_twofaccounts_collection_with_secret()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -383,9 +347,7 @@ public function test_accounts_returns_twofaccounts_collection_with_secret()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_accounts_of_missing_group_returns_not_found() public function test_accounts_of_missing_group_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -396,9 +358,7 @@ public function test_accounts_of_missing_group_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_accounts_of_another_user_group_is_forbidden() public function test_accounts_of_another_user_group_is_forbidden()
{ {
$response = $this->actingAs($this->anotherUser, 'api-guard') $response = $this->actingAs($this->anotherUser, 'api-guard')
@ -411,9 +371,8 @@ public function test_accounts_of_another_user_group_is_forbidden()
/** /**
* test Group deletion via API * test Group deletion via API
*
* @test
*/ */
#[Test]
public function test_destroy_group_returns_success() public function test_destroy_group_returns_success()
{ {
$group = Group::factory()->for($this->user)->create(); $group = Group::factory()->for($this->user)->create();
@ -425,9 +384,8 @@ public function test_destroy_group_returns_success()
/** /**
* test Group deletion via API * test Group deletion via API
*
* @test
*/ */
#[Test]
public function test_destroy_missing_group_returns_not_found() public function test_destroy_missing_group_returns_not_found()
{ {
$this->actingAs($this->user, 'api-guard') $this->actingAs($this->user, 'api-guard')
@ -438,9 +396,7 @@ public function test_destroy_missing_group_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_destroy_group_of_another_user_is_forbidden() public function test_destroy_group_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->anotherUser, 'api-guard') $response = $this->actingAs($this->anotherUser, 'api-guard')
@ -451,9 +407,7 @@ public function test_destroy_group_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_destroy_group_resets_user_preferences() public function test_destroy_group_resets_user_preferences()
{ {
// Set the default group to a specific one // Set the default group to a specific one
@ -474,9 +428,7 @@ public function test_destroy_group_resets_user_preferences()
$this->assertEquals(0, $this->user->preferences['activeGroup']); $this->assertEquals(0, $this->user->preferences['activeGroup']);
} }
/** #[Test]
* @test
*/
public function test_twofaccount_is_released_on_group_destroy() public function test_twofaccount_is_released_on_group_destroy()
{ {
$this->actingAs($this->user, 'api-guard') $this->actingAs($this->user, 'api-guard')

View File

@ -7,6 +7,7 @@
use App\Models\User; use App\Models\User;
use Illuminate\Http\UploadedFile; use Illuminate\Http\UploadedFile;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -27,9 +28,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_upload_icon_returns_filename() public function test_upload_icon_returns_filename()
{ {
$file = UploadedFile::fake()->image('testIcon.jpg'); $file = UploadedFile::fake()->image('testIcon.jpg');
@ -44,9 +43,7 @@ public function test_upload_icon_returns_filename()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_upload_with_invalid_data_returns_validation_error() public function test_upload_with_invalid_data_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -56,9 +53,7 @@ public function test_upload_with_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_fetch_logo_returns_filename() public function test_fetch_logo_returns_filename()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -71,9 +66,7 @@ public function test_fetch_logo_returns_filename()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_fetch_unknown_logo_returns_nothing() public function test_fetch_unknown_logo_returns_nothing()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -83,9 +76,7 @@ public function test_fetch_unknown_logo_returns_nothing()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_delete_icon_returns_success() public function test_delete_icon_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -93,9 +84,7 @@ public function test_delete_icon_returns_success()
->assertNoContent(204); ->assertNoContent(204);
} }
/** #[Test]
* @test
*/
public function test_delete_invalid_icon_returns_success() public function test_delete_invalid_icon_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -103,9 +92,7 @@ public function test_delete_invalid_icon_returns_success()
->assertNoContent(204); ->assertNoContent(204);
} }
/** #[Test]
* @test
*/
public function test_delete_icon_of_another_user_is_forbidden() public function test_delete_icon_of_another_user_is_forbidden()
{ {
$anotherUser = User::factory()->create(); $anotherUser = User::factory()->create();

View File

@ -6,6 +6,7 @@
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use App\Models\User; use App\Models\User;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -27,9 +28,6 @@ class QrCodeControllerTest extends FeatureTestCase
*/ */
protected $twofaccount; protected $twofaccount;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -49,9 +47,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_qrcode_returns_base64_image() public function test_show_qrcode_returns_base64_image()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -64,9 +60,7 @@ public function test_show_qrcode_returns_base64_image()
$this->assertStringStartsWith('data:image/svg+xml;base64', $response->getData()->qrcode); $this->assertStringStartsWith('data:image/svg+xml;base64', $response->getData()->qrcode);
} }
/** #[Test]
* @test
*/
public function test_show_missing_qrcode_returns_not_found() public function test_show_missing_qrcode_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -77,9 +71,7 @@ public function test_show_missing_qrcode_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_qrcode_of_another_user_is_forbidden() public function test_show_qrcode_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->anotherUser, 'api-guard') $response = $this->actingAs($this->anotherUser, 'api-guard')
@ -90,9 +82,7 @@ public function test_show_qrcode_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_decode_qrcode_return_success() public function test_decode_qrcode_return_success()
{ {
$file = LocalFile::fake()->validQrcode(); $file = LocalFile::fake()->validQrcode();
@ -109,9 +99,7 @@ public function test_decode_qrcode_return_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_decode_missing_qrcode_return_validation_error() public function test_decode_missing_qrcode_return_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -121,9 +109,7 @@ public function test_decode_missing_qrcode_return_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_decode_invalid_qrcode_return_bad_request() public function test_decode_invalid_qrcode_return_bad_request()
{ {
$file = LocalFile::fake()->invalidQrcode(); $file = LocalFile::fake()->invalidQrcode();

View File

@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -41,9 +42,6 @@ class SettingControllerTest extends FeatureTestCase
private const USER_DEFINED_SETTING_CHANGED_VALUE = 'mySetting'; private const USER_DEFINED_SETTING_CHANGED_VALUE = 'mySetting';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -52,9 +50,7 @@ public function setUp() : void
$this->admin = User::factory()->administrator()->create(); $this->admin = User::factory()->administrator()->create();
} }
/** #[Test]
* @test
*/
public function test_all_controller_routes_are_protected_by_admin_middleware() public function test_all_controller_routes_are_protected_by_admin_middleware()
{ {
$routes = Route::getRoutes()->getRoutes(); $routes = Route::getRoutes()->getRoutes();
@ -70,9 +66,7 @@ public function test_all_controller_routes_are_protected_by_admin_middleware()
} }
} }
/** #[Test]
* @test
*/
public function test_index_returns_setting_collection() public function test_index_returns_setting_collection()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -83,9 +77,7 @@ public function test_index_returns_setting_collection()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_index_is_forbidden_to_users() public function test_index_is_forbidden_to_users()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -96,9 +88,7 @@ public function test_index_is_forbidden_to_users()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_native_unchanged_setting_returns_consistent_value() public function test_show_native_unchanged_setting_returns_consistent_value()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -110,9 +100,7 @@ public function test_show_native_unchanged_setting_returns_consistent_value()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_native_changed_setting_returns_consistent_value() public function test_show_native_changed_setting_returns_consistent_value()
{ {
Settings::set(self::TWOFAUTH_NATIVE_SETTING, self::TWOFAUTH_NATIVE_SETTING_CHANGED_VALUE); Settings::set(self::TWOFAUTH_NATIVE_SETTING, self::TWOFAUTH_NATIVE_SETTING_CHANGED_VALUE);
@ -126,9 +114,7 @@ public function test_show_native_changed_setting_returns_consistent_value()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_custom_user_setting_returns_consistent_value() public function test_show_custom_user_setting_returns_consistent_value()
{ {
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE); Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
@ -142,9 +128,7 @@ public function test_show_custom_user_setting_returns_consistent_value()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_missing_setting_returns_not_found() public function test_show_missing_setting_returns_not_found()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -152,9 +136,7 @@ public function test_show_missing_setting_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_show_setting_is_forbidden_to_users() public function test_show_setting_is_forbidden_to_users()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -165,9 +147,7 @@ public function test_show_setting_is_forbidden_to_users()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_custom_user_setting_returns_success() public function test_store_custom_user_setting_returns_success()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -182,9 +162,7 @@ public function test_store_custom_user_setting_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_invalid_custom_user_setting_returns_validation_error() public function test_store_invalid_custom_user_setting_returns_validation_error()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -195,9 +173,7 @@ public function test_store_invalid_custom_user_setting_returns_validation_error(
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_store_existing_custom_user_setting_returns_validation_error() public function test_store_existing_custom_user_setting_returns_validation_error()
{ {
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE); Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
@ -210,9 +186,7 @@ public function test_store_existing_custom_user_setting_returns_validation_error
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_update_unchanged_native_setting_returns_updated_setting() public function test_update_unchanged_native_setting_returns_updated_setting()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -226,9 +200,7 @@ public function test_update_unchanged_native_setting_returns_updated_setting()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_custom_user_setting_returns_updated_setting() public function test_update_custom_user_setting_returns_updated_setting()
{ {
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE); Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
@ -244,9 +216,7 @@ public function test_update_custom_user_setting_returns_updated_setting()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_missing_user_setting_returns_created_setting() public function test_update_missing_user_setting_returns_created_setting()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -260,9 +230,7 @@ public function test_update_missing_user_setting_returns_created_setting()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_destroy_user_setting_returns_success() public function test_destroy_user_setting_returns_success()
{ {
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE); Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);
@ -272,9 +240,7 @@ public function test_destroy_user_setting_returns_success()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_destroy_native_setting_returns_bad_request() public function test_destroy_native_setting_returns_bad_request()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -286,9 +252,7 @@ public function test_destroy_native_setting_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_destroy_missing_user_setting_returns_not_found() public function test_destroy_missing_user_setting_returns_not_found()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -296,9 +260,7 @@ public function test_destroy_missing_user_setting_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_destroy_is_forbidden_to_users() public function test_destroy_is_forbidden_to_users()
{ {
Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE); Settings::set(self::USER_DEFINED_SETTING, self::USER_DEFINED_SETTING_VALUE);

View File

@ -19,6 +19,7 @@
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
use Tests\Data\MigrationTestData; use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
@ -178,9 +179,6 @@ class TwoFAccountControllerTest extends FeatureTestCase
'secret' => OtpTestData::SECRET, 'secret' => OtpTestData::SECRET,
]; ];
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -208,9 +206,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
#[DataProvider('indexUrlParameterProvider')] #[DataProvider('indexUrlParameterProvider')]
public function test_index_returns_user_twofaccounts_only($urlParameter, $expected) public function test_index_returns_user_twofaccounts_only($urlParameter, $expected)
{ {
@ -252,9 +248,7 @@ public static function indexUrlParameterProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_show_returns_twofaccount_resource_with_secret() public function test_show_returns_twofaccount_resource_with_secret()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -263,9 +257,7 @@ public function test_show_returns_twofaccount_resource_with_secret()
->assertJsonStructure(self::VALID_RESOURCE_STRUCTURE_WITH_SECRET); ->assertJsonStructure(self::VALID_RESOURCE_STRUCTURE_WITH_SECRET);
} }
/** #[Test]
* @test
*/
public function test_show_returns_twofaccount_resource_without_secret() public function test_show_returns_twofaccount_resource_without_secret()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -274,9 +266,7 @@ public function test_show_returns_twofaccount_resource_without_secret()
->assertJsonStructure(self::VALID_RESOURCE_STRUCTURE_WITHOUT_SECRET); ->assertJsonStructure(self::VALID_RESOURCE_STRUCTURE_WITHOUT_SECRET);
} }
/** //#[Test]
* @test
*/
// public function test_show_twofaccount_with_indeciphered_data_returns_replaced_data() // public function test_show_twofaccount_with_indeciphered_data_returns_replaced_data()
// { // {
// $dbEncryptionService = resolve('App\Services\DbEncryptionService'); // $dbEncryptionService = resolve('App\Services\DbEncryptionService');
@ -299,9 +289,7 @@ public function test_show_returns_twofaccount_resource_without_secret()
// ]); // ]);
// } // }
/** #[Test]
* @test
*/
public function test_show_missing_twofaccount_returns_not_found() public function test_show_missing_twofaccount_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -312,9 +300,7 @@ public function test_show_missing_twofaccount_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_twofaccount_of_another_user_is_forbidden() public function test_show_twofaccount_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -325,9 +311,7 @@ public function test_show_twofaccount_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
#[DataProvider('accountCreationProvider')] #[DataProvider('accountCreationProvider')]
public function test_store_without_encryption_returns_success_with_consistent_resource_structure($payload, $expected) public function test_store_without_encryption_returns_success_with_consistent_resource_structure($payload, $expected)
{ {
@ -341,9 +325,7 @@ public function test_store_without_encryption_returns_success_with_consistent_re
->assertJsonFragment($expected); ->assertJsonFragment($expected);
} }
/** #[Test]
* @test
*/
#[DataProvider('accountCreationProvider')] #[DataProvider('accountCreationProvider')]
public function test_store_with_encryption_returns_success_with_consistent_resource_structure($payload, $expected) public function test_store_with_encryption_returns_success_with_consistent_resource_structure($payload, $expected)
{ {
@ -406,9 +388,7 @@ public static function accountCreationProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_store_with_invalid_uri_returns_validation_error() public function test_store_with_invalid_uri_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -418,9 +398,7 @@ public function test_store_with_invalid_uri_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_store_assigns_created_account_when_default_group_is_a_specific_one() public function test_store_assigns_created_account_when_default_group_is_a_specific_one()
{ {
// Set the default group to a specific one // Set the default group to a specific one
@ -436,9 +414,7 @@ public function test_store_assigns_created_account_when_default_group_is_a_speci
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_assigns_created_account_when_default_group_is_the_active_one() public function test_store_assigns_created_account_when_default_group_is_the_active_one()
{ {
// Set the default group to be the active one // Set the default group to be the active one
@ -456,9 +432,7 @@ public function test_store_assigns_created_account_when_default_group_is_the_act
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_assigns_created_account_when_default_group_is_no_group() public function test_store_assigns_created_account_when_default_group_is_no_group()
{ {
// Set the default group to No group // Set the default group to No group
@ -474,9 +448,7 @@ public function test_store_assigns_created_account_when_default_group_is_no_grou
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_assigns_created_account_when_default_group_does_not_exist() public function test_store_assigns_created_account_when_default_group_does_not_exist()
{ {
// Set the default group to a non-existing one // Set the default group to a non-existing one
@ -492,9 +464,7 @@ public function test_store_assigns_created_account_when_default_group_does_not_e
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_totp_returns_success_with_updated_resource() public function test_update_totp_returns_success_with_updated_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -503,9 +473,7 @@ public function test_update_totp_returns_success_with_updated_resource()
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
} }
/** #[Test]
* @test
*/
public function test_update_hotp_returns_success_with_updated_resource() public function test_update_hotp_returns_success_with_updated_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -514,9 +482,7 @@ public function test_update_hotp_returns_success_with_updated_resource()
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_HOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_HOTP);
} }
/** #[Test]
* @test
*/
public function test_update_missing_twofaccount_returns_not_found() public function test_update_missing_twofaccount_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -524,9 +490,7 @@ public function test_update_missing_twofaccount_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_update_twofaccount_with_invalid_data_returns_validation_error() public function test_update_twofaccount_with_invalid_data_returns_validation_error()
{ {
$twofaccount = TwoFAccount::factory()->create(); $twofaccount = TwoFAccount::factory()->create();
@ -536,9 +500,7 @@ public function test_update_twofaccount_with_invalid_data_returns_validation_err
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_update_twofaccount_of_another_user_is_forbidden() public function test_update_twofaccount_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -549,9 +511,7 @@ public function test_update_twofaccount_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_migrate_valid_gauth_payload_returns_success_with_consistent_resources() public function test_migrate_valid_gauth_payload_returns_success_with_consistent_resources()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -585,9 +545,7 @@ public function test_migrate_valid_gauth_payload_returns_success_with_consistent
]); ]);
} }
/** #[Test]
* @test
*/
public function test_migrate_with_invalid_gauth_payload_returns_validation_error() public function test_migrate_with_invalid_gauth_payload_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -597,9 +555,7 @@ public function test_migrate_with_invalid_gauth_payload_returns_validation_error
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_migrate_payload_with_duplicates_returns_negative_ids() public function test_migrate_payload_with_duplicates_returns_negative_ids()
{ {
$twofaccount = TwoFAccount::factory()->for($this->user)->create([ $twofaccount = TwoFAccount::factory()->for($this->user)->create([
@ -643,9 +599,7 @@ public function test_migrate_payload_with_duplicates_returns_negative_ids()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_migrate_identify_duplicates_in_authenticated_user_twofaccounts_only() public function test_migrate_identify_duplicates_in_authenticated_user_twofaccounts_only()
{ {
$twofaccount = TwoFAccount::factory()->for($this->anotherUser)->create([ $twofaccount = TwoFAccount::factory()->for($this->anotherUser)->create([
@ -689,9 +643,7 @@ public function test_migrate_identify_duplicates_in_authenticated_user_twofaccou
]); ]);
} }
/** #[Test]
* @test
*/
public function test_migrate_invalid_gauth_payload_returns_bad_request() public function test_migrate_invalid_gauth_payload_returns_bad_request()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -704,9 +656,7 @@ public function test_migrate_invalid_gauth_payload_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_migrate_valid_aegis_json_file_returns_success() public function test_migrate_valid_aegis_json_file_returns_success()
{ {
$file = LocalFile::fake()->validAegisJsonFile(); $file = LocalFile::fake()->validAegisJsonFile();
@ -754,9 +704,7 @@ public function test_migrate_valid_aegis_json_file_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidAegisJsonFileProvider')] #[DataProvider('invalidAegisJsonFileProvider')]
public function test_migrate_invalid_aegis_json_file_returns_bad_request($file) public function test_migrate_invalid_aegis_json_file_returns_bad_request($file)
{ {
@ -783,9 +731,7 @@ public static function invalidAegisJsonFileProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('validPlainTextFileProvider')] #[DataProvider('validPlainTextFileProvider')]
public function test_migrate_valid_plain_text_file_returns_success($file) public function test_migrate_valid_plain_text_file_returns_success($file)
{ {
@ -847,9 +793,7 @@ public static function validPlainTextFileProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidPlainTextFileProvider')] #[DataProvider('invalidPlainTextFileProvider')]
public function test_migrate_invalid_plain_text_file_returns_bad_request($file) public function test_migrate_invalid_plain_text_file_returns_bad_request($file)
{ {
@ -882,9 +826,7 @@ public static function invalidPlainTextFileProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_reorder_returns_success() public function test_reorder_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -897,9 +839,7 @@ public function test_reorder_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_reorder_with_invalid_data_returns_validation_error() public function test_reorder_with_invalid_data_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -909,9 +849,7 @@ public function test_reorder_with_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_reorder_twofaccounts_of_another_user_is_forbidden() public function test_reorder_twofaccounts_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -924,9 +862,7 @@ public function test_reorder_twofaccounts_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_preview_returns_success_with_resource() public function test_preview_returns_success_with_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -937,9 +873,7 @@ public function test_preview_returns_success_with_resource()
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_CUSTOM_TOTP);
} }
/** #[Test]
* @test
*/
public function test_preview_with_invalid_data_returns_validation_error() public function test_preview_with_invalid_data_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -949,9 +883,7 @@ public function test_preview_with_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_preview_with_unreachable_image_returns_success() public function test_preview_with_unreachable_image_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -964,9 +896,7 @@ public function test_preview_with_unreachable_image_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_export_returns_json_migration_resource() public function test_export_returns_json_migration_resource()
{ {
$this->twofaccountA = TwoFAccount::factory()->for($this->user)->create(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP); $this->twofaccountA = TwoFAccount::factory()->for($this->user)->create(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP);
@ -980,9 +910,7 @@ public function test_export_returns_json_migration_resource()
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_DEFAULT_HOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_DEFAULT_HOTP);
} }
/** #[Test]
* @test
*/
public function test_export_too_many_ids_returns_bad_request() public function test_export_too_many_ids_returns_bad_request()
{ {
TwoFAccount::factory()->count(102)->for($this->user)->create(); TwoFAccount::factory()->count(102)->for($this->user)->create();
@ -998,9 +926,7 @@ public function test_export_too_many_ids_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_export_missing_twofaccount_returns_existing_ones_only() public function test_export_missing_twofaccount_returns_existing_ones_only()
{ {
$this->twofaccountA = TwoFAccount::factory()->for($this->user)->create(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP); $this->twofaccountA = TwoFAccount::factory()->for($this->user)->create(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP);
@ -1010,9 +936,7 @@ public function test_export_missing_twofaccount_returns_existing_ones_only()
->assertJsonFragment(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP); ->assertJsonFragment(self::JSON_FRAGMENTS_FOR_DEFAULT_TOTP);
} }
/** #[Test]
* @test
*/
public function test_export_twofaccount_of_another_user_is_forbidden() public function test_export_twofaccount_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1023,9 +947,7 @@ public function test_export_twofaccount_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resource() public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resource()
{ {
$twofaccount = TwoFAccount::factory()->for($this->user)->create([ $twofaccount = TwoFAccount::factory()->for($this->user)->create([
@ -1050,9 +972,7 @@ public function test_get_otp_using_totp_twofaccount_id_returns_consistent_resour
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_totp_uri_returns_consistent_resource() public function test_get_otp_by_posting_totp_uri_returns_consistent_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1067,9 +987,7 @@ public function test_get_otp_by_posting_totp_uri_returns_consistent_resource()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_totp_parameters_returns_consistent_resource() public function test_get_otp_by_posting_totp_parameters_returns_consistent_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1082,9 +1000,7 @@ public function test_get_otp_by_posting_totp_parameters_returns_consistent_resou
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resource() public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resource()
{ {
$twofaccount = TwoFAccount::factory()->for($this->user)->create([ $twofaccount = TwoFAccount::factory()->for($this->user)->create([
@ -1109,9 +1025,7 @@ public function test_get_otp_using_hotp_twofaccount_id_returns_consistent_resour
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_hotp_uri_returns_consistent_resource() public function test_get_otp_by_posting_hotp_uri_returns_consistent_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1126,9 +1040,7 @@ public function test_get_otp_by_posting_hotp_uri_returns_consistent_resource()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_hotp_parameters_returns_consistent_resource() public function test_get_otp_by_posting_hotp_parameters_returns_consistent_resource()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1141,9 +1053,7 @@ public function test_get_otp_by_posting_hotp_parameters_returns_consistent_resou
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_multiple_inputs_returns_bad_request() public function test_get_otp_by_posting_multiple_inputs_returns_bad_request()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1158,9 +1068,7 @@ public function test_get_otp_by_posting_multiple_inputs_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_request() public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_request()
{ {
Settings::set('useEncryption', true); Settings::set('useEncryption', true);
@ -1181,9 +1089,7 @@ public function test_get_otp_using_indecipherable_twofaccount_id_returns_bad_req
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_otp_using_missing_twofaccount_id_returns_not_found() public function test_get_otp_using_missing_twofaccount_id_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1191,9 +1097,7 @@ public function test_get_otp_using_missing_twofaccount_id_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_invalid_uri_returns_validation_error() public function test_get_otp_by_posting_invalid_uri_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1203,9 +1107,7 @@ public function test_get_otp_by_posting_invalid_uri_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_get_otp_by_posting_invalid_parameters_returns_validation_error() public function test_get_otp_by_posting_invalid_parameters_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1213,9 +1115,7 @@ public function test_get_otp_by_posting_invalid_parameters_returns_validation_er
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_get_otp_of_another_user_twofaccount_is_forbidden() public function test_get_otp_of_another_user_twofaccount_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1226,9 +1126,7 @@ public function test_get_otp_of_another_user_twofaccount_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_count_returns_right_number_of_twofaccounts() public function test_count_returns_right_number_of_twofaccounts()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1239,9 +1137,7 @@ public function test_count_returns_right_number_of_twofaccounts()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_withdraw_returns_success() public function test_withdraw_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1252,9 +1148,7 @@ public function test_withdraw_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_withdraw_too_many_ids_returns_bad_request() public function test_withdraw_too_many_ids_returns_bad_request()
{ {
TwoFAccount::factory()->count(102)->for($this->user)->create(); TwoFAccount::factory()->count(102)->for($this->user)->create();
@ -1270,9 +1164,7 @@ public function test_withdraw_too_many_ids_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_destroy_twofaccount_returns_success() public function test_destroy_twofaccount_returns_success()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1280,9 +1172,7 @@ public function test_destroy_twofaccount_returns_success()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_destroy_missing_twofaccount_returns_not_found() public function test_destroy_missing_twofaccount_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1290,9 +1180,7 @@ public function test_destroy_missing_twofaccount_returns_not_found()
->assertNotFound(); ->assertNotFound();
} }
/** #[Test]
* @test
*/
public function test_destroy_twofaccount_of_another_user_is_forbidden() public function test_destroy_twofaccount_of_another_user_is_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -1303,9 +1191,7 @@ public function test_destroy_twofaccount_of_another_user_is_forbidden()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_batch_destroy_twofaccount_returns_success() public function test_batch_destroy_twofaccount_returns_success()
{ {
TwoFAccount::factory()->count(3)->for($this->user)->create(); TwoFAccount::factory()->count(3)->for($this->user)->create();
@ -1315,9 +1201,7 @@ public function test_batch_destroy_twofaccount_returns_success()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_batch_destroy_too_many_twofaccounts_returns_bad_request() public function test_batch_destroy_too_many_twofaccounts_returns_bad_request()
{ {
TwoFAccount::factory()->count(102)->for($this->user)->create(); TwoFAccount::factory()->count(102)->for($this->user)->create();
@ -1333,9 +1217,7 @@ public function test_batch_destroy_too_many_twofaccounts_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_batch_destroy_twofaccount_of_another_user_is_forbidden() public function test_batch_destroy_twofaccount_of_another_user_is_forbidden()
{ {
TwoFAccount::factory()->count(2)->for($this->anotherUser)->create(); TwoFAccount::factory()->count(2)->for($this->anotherUser)->create();

View File

@ -24,6 +24,7 @@
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
#[CoversClass(UserManagerController::class)] #[CoversClass(UserManagerController::class)]
@ -52,9 +53,6 @@ class UserManagerControllerTest extends FeatureTestCase
private const PASSWORD = 'password'; private const PASSWORD = 'password';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -69,9 +67,7 @@ public function setUp() : void
} }
} }
/** #[Test]
* @test
*/
public function test_all_controller_routes_are_protected_by_admin_middleware() public function test_all_controller_routes_are_protected_by_admin_middleware()
{ {
$routes = Route::getRoutes()->getRoutes(); $routes = Route::getRoutes()->getRoutes();
@ -87,9 +83,7 @@ public function test_all_controller_routes_are_protected_by_admin_middleware()
} }
} }
/** #[Test]
* @test
*/
public function test_index_returns_all_users_with_expected_UserManagerResources() : void public function test_index_returns_all_users_with_expected_UserManagerResources() : void
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -130,9 +124,7 @@ public function test_index_returns_all_users_with_expected_UserManagerResources(
]); ]);
} }
/** #[Test]
* @test
*/
public function test_show_returns_the_expected_UserManagerResource() : void public function test_show_returns_the_expected_UserManagerResource() : void
{ {
$this->actingAs($this->admin, 'api-guard') $this->actingAs($this->admin, 'api-guard')
@ -155,9 +147,7 @@ public function test_show_returns_the_expected_UserManagerResource() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_resetPassword_resets_password_and_sends_password_reset_to_user() public function test_resetPassword_resets_password_and_sends_password_reset_to_user()
{ {
Notification::fake(); Notification::fake();
@ -181,9 +171,7 @@ public function test_resetPassword_resets_password_and_sends_password_reset_to_u
}); });
} }
/** #[Test]
* @test
*/
public function test_resetPassword_returns_UserManagerResource() public function test_resetPassword_returns_UserManagerResource()
{ {
Notification::fake(); Notification::fake();
@ -199,9 +187,7 @@ public function test_resetPassword_returns_UserManagerResource()
$response->assertExactJson($resources->response($request)->getData(true)); $response->assertExactJson($resources->response($request)->getData(true));
} }
/** #[Test]
* @test
*/
public function test_resetPassword_does_not_notify_when_reset_failed_and_returns_error() public function test_resetPassword_does_not_notify_when_reset_failed_and_returns_error()
{ {
Notification::fake(); Notification::fake();
@ -228,9 +214,7 @@ public function test_resetPassword_does_not_notify_when_reset_failed_and_returns
Notification::assertNothingSent(); Notification::assertNothingSent();
} }
/** #[Test]
* @test
*/
public function test_resetPassword_returns_error_when_notify_send_failed() public function test_resetPassword_returns_error_when_notify_send_failed()
{ {
Notification::fake(); Notification::fake();
@ -259,9 +243,7 @@ public function test_resetPassword_returns_error_when_notify_send_failed()
Notification::assertNothingSent(); Notification::assertNothingSent();
} }
/** #[Test]
* @test
*/
public function test_store_creates_the_user_and_returns_success() public function test_store_creates_the_user_and_returns_success()
{ {
$this->actingAs($this->admin, 'api-guard') $this->actingAs($this->admin, 'api-guard')
@ -280,9 +262,7 @@ public function test_store_creates_the_user_and_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_store_returns_UserManagerResource_of_created_user() : void public function test_store_returns_UserManagerResource_of_created_user() : void
{ {
$path = '/api/v1/users'; $path = '/api/v1/users';
@ -300,9 +280,7 @@ public function test_store_returns_UserManagerResource_of_created_user() : void
$response->assertExactJson($resource->response($request)->getData(true)); $response->assertExactJson($resource->response($request)->getData(true));
} }
/** #[Test]
* @test
*/
public function test_store_returns_UserManagerResource_of_created_admin() : void public function test_store_returns_UserManagerResource_of_created_admin() : void
{ {
$path = '/api/v1/users'; $path = '/api/v1/users';
@ -321,9 +299,7 @@ public function test_store_returns_UserManagerResource_of_created_admin() : void
$response->assertExactJson($resource->response($request)->getData(true)); $response->assertExactJson($resource->response($request)->getData(true));
} }
/** #[Test]
* @test
*/
public function test_revokePATs_flushes_pats() public function test_revokePATs_flushes_pats()
{ {
Artisan::call('passport:install', [ Artisan::call('passport:install', [
@ -350,9 +326,7 @@ public function test_revokePATs_flushes_pats()
$this->assertCount(0, $tokens); $this->assertCount(0, $tokens);
} }
/** #[Test]
* @test
*/
public function test_revokePATs_returns_no_content() public function test_revokePATs_returns_no_content()
{ {
$this->actingAs($this->admin, 'api-guard') $this->actingAs($this->admin, 'api-guard')
@ -360,9 +334,7 @@ public function test_revokePATs_returns_no_content()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_revokePATs_always_returns_no_content() public function test_revokePATs_always_returns_no_content()
{ {
// a fresh user has no token // a fresh user has no token
@ -373,9 +345,7 @@ public function test_revokePATs_always_returns_no_content()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_revokeWebauthnCredentials_flushes_credentials() public function test_revokeWebauthnCredentials_flushes_credentials()
{ {
DB::table('webauthn_credentials')->insert([ DB::table('webauthn_credentials')->insert([
@ -401,9 +371,7 @@ public function test_revokeWebauthnCredentials_flushes_credentials()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_revokeWebauthnCredentials_returns_no_content() public function test_revokeWebauthnCredentials_returns_no_content()
{ {
DB::table('webauthn_credentials')->insert([ DB::table('webauthn_credentials')->insert([
@ -426,9 +394,7 @@ public function test_revokeWebauthnCredentials_returns_no_content()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_revokeWebauthnCredentials_always_returns_no_content() public function test_revokeWebauthnCredentials_always_returns_no_content()
{ {
DB::table('webauthn_credentials')->delete(); DB::table('webauthn_credentials')->delete();
@ -438,9 +404,7 @@ public function test_revokeWebauthnCredentials_always_returns_no_content()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_revokeWebauthnCredentials_resets_useWebauthnOnly_user_preference() public function test_revokeWebauthnCredentials_resets_useWebauthnOnly_user_preference()
{ {
$this->user['preferences->useWebauthnOnly'] = true; $this->user['preferences->useWebauthnOnly'] = true;
@ -455,9 +419,7 @@ public function test_revokeWebauthnCredentials_resets_useWebauthnOnly_user_prefe
$this->assertFalse($this->user->preferences['useWebauthnOnly']); $this->assertFalse($this->user->preferences['useWebauthnOnly']);
} }
/** #[Test]
* @test
*/
public function test_destroy_returns_no_content() public function test_destroy_returns_no_content()
{ {
$user = User::factory()->create(); $user = User::factory()->create();
@ -467,9 +429,7 @@ public function test_destroy_returns_no_content()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_destroy_the_only_admin_returns_forbidden() public function test_destroy_the_only_admin_returns_forbidden()
{ {
$this->actingAs($this->admin, 'api-guard') $this->actingAs($this->admin, 'api-guard')
@ -477,9 +437,7 @@ public function test_destroy_the_only_admin_returns_forbidden()
->assertForbidden(); ->assertForbidden();
} }
/** #[Test]
* @test
*/
public function test_promote_changes_admin_status() : void public function test_promote_changes_admin_status() : void
{ {
$this->actingAs($this->admin, 'api-guard') $this->actingAs($this->admin, 'api-guard')
@ -493,9 +451,7 @@ public function test_promote_changes_admin_status() : void
$this->assertTrue($this->user->isAdministrator()); $this->assertTrue($this->user->isAdministrator());
} }
/** #[Test]
* @test
*/
public function test_promote_returns_UserManagerResource() : void public function test_promote_returns_UserManagerResource() : void
{ {
$path = '/api/v1/users/' . $this->user->id . '/promote'; $path = '/api/v1/users/' . $this->user->id . '/promote';
@ -512,9 +468,7 @@ public function test_promote_returns_UserManagerResource() : void
$response->assertExactJson($resources->response($request)->getData(true)); $response->assertExactJson($resources->response($request)->getData(true));
} }
/** #[Test]
* @test
*/
public function test_demote_returns_UserManagerResource() : void public function test_demote_returns_UserManagerResource() : void
{ {
$anotherAdmin = User::factory()->administrator()->create(); $anotherAdmin = User::factory()->administrator()->create();
@ -533,9 +487,7 @@ public function test_demote_returns_UserManagerResource() : void
$response->assertExactJson($resources->response($request)->getData(true)); $response->assertExactJson($resources->response($request)->getData(true));
} }
/** #[Test]
* @test
*/
public function test_demote_the_only_admin_returns_forbidden() : void public function test_demote_the_only_admin_returns_forbidden() : void
{ {
$this->assertTrue(User::admins()->count() == 1); $this->assertTrue(User::admins()->count() == 1);
@ -547,9 +499,7 @@ public function test_demote_the_only_admin_returns_forbidden() : void
->assertForbidden(); ->assertForbidden();
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_all_preserved_entries() : void public function test_authentications_returns_all_preserved_entries() : void
{ {
AuthLog::factory()->for($this->user, 'authenticatable')->duringLastYear()->create(); AuthLog::factory()->for($this->user, 'authenticatable')->duringLastYear()->create();
@ -566,9 +516,7 @@ public function test_authentications_returns_all_preserved_entries() : void
->assertJsonCount(7); ->assertJsonCount(7);
} }
/** #[Test]
* @test
*/
public function test_authentications_does_not_return_old_entries() : void public function test_authentications_does_not_return_old_entries() : void
{ {
AuthLog::factory()->for($this->user, 'authenticatable')->beforeLastYear()->create(); AuthLog::factory()->for($this->user, 'authenticatable')->beforeLastYear()->create();
@ -579,9 +527,7 @@ public function test_authentications_does_not_return_old_entries() : void
->assertJsonCount(0); ->assertJsonCount(0);
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_user_entries_only() : void public function test_authentications_returns_user_entries_only() : void
{ {
AuthLog::factory()->for($this->admin, 'authenticatable')->create(); AuthLog::factory()->for($this->admin, 'authenticatable')->create();
@ -594,9 +540,7 @@ public function test_authentications_returns_user_entries_only() : void
$this->assertEquals($response->getData()[0]->id, $this->user->id); $this->assertEquals($response->getData()[0]->id, $this->user->id);
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_expected_resource() : void public function test_authentications_returns_expected_resource() : void
{ {
AuthLog::factory()->for($this->user, 'authenticatable')->create(); AuthLog::factory()->for($this->user, 'authenticatable')->create();
@ -620,9 +564,7 @@ public function test_authentications_returns_expected_resource() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_resource_with_timezoned_dates() : void public function test_authentications_returns_resource_with_timezoned_dates() : void
{ {
$timezone = 'Europe/Paris'; $timezone = 'Europe/Paris';
@ -649,9 +591,7 @@ public function test_authentications_returns_resource_with_timezoned_dates() : v
$this->assertTrue($logout_at->isSameMinute($timezonedNow)); $this->assertTrue($logout_at->isSameMinute($timezonedNow));
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_loginless_entries() : void public function test_authentications_returns_loginless_entries() : void
{ {
$this->logUserOut(); $this->logUserOut();
@ -664,9 +604,7 @@ public function test_authentications_returns_loginless_entries() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_logoutless_entries() : void public function test_authentications_returns_logoutless_entries() : void
{ {
$this->logUserIn(); $this->logUserIn();
@ -679,9 +617,7 @@ public function test_authentications_returns_logoutless_entries() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_failed_entry() : void public function test_authentications_returns_failed_entry() : void
{ {
$this->json('POST', '/user/login', [ $this->json('POST', '/user/login', [
@ -697,9 +633,7 @@ public function test_authentications_returns_failed_entry() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_last_month_entries() : void public function test_authentications_returns_last_month_entries() : void
{ {
$this->travel(-2)->months(); $this->travel(-2)->months();
@ -714,9 +648,7 @@ public function test_authentications_returns_last_month_entries() : void
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now())); $this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()));
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_last_three_months_entries() : void public function test_authentications_returns_last_three_months_entries() : void
{ {
$this->travel(-100)->days(); $this->travel(-100)->days();
@ -733,9 +665,7 @@ public function test_authentications_returns_last_three_months_entries() : void
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subDays(80))); $this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subDays(80)));
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_last_six_months_entries() : void public function test_authentications_returns_last_six_months_entries() : void
{ {
$this->travel(-7)->months(); $this->travel(-7)->months();
@ -752,9 +682,7 @@ public function test_authentications_returns_last_six_months_entries() : void
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subMonths(5))); $this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subMonths(5)));
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_last_year_entries() : void public function test_authentications_returns_last_year_entries() : void
{ {
$this->travel(-13)->months(); $this->travel(-13)->months();
@ -771,9 +699,7 @@ public function test_authentications_returns_last_year_entries() : void
$this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subMonths(11))); $this->assertTrue(Carbon::parse($response->getData()[0]->login_at)->isSameDay(now()->subMonths(11)));
} }
/** #[Test]
* @test
*/
#[DataProvider('LimitProvider')] #[DataProvider('LimitProvider')]
public function test_authentications_returns_limited_entries($limit) : void public function test_authentications_returns_limited_entries($limit) : void
{ {
@ -801,9 +727,7 @@ public static function LimitProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_authentications_returns_expected_ip_and_useragent_chunks() : void public function test_authentications_returns_expected_ip_and_useragent_chunks() : void
{ {
AuthLog::factory()->for($this->user, 'authenticatable')->create([ AuthLog::factory()->for($this->user, 'authenticatable')->create([
@ -821,9 +745,7 @@ public function test_authentications_returns_expected_ip_and_useragent_chunks()
]); ]);
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidQueryParameterProvider')] #[DataProvider('invalidQueryParameterProvider')]
public function test_authentications_with_invalid_limit_returns_validation_error($limit) : void public function test_authentications_with_invalid_limit_returns_validation_error($limit) : void
{ {
@ -832,9 +754,7 @@ public function test_authentications_with_invalid_limit_returns_validation_error
->assertInvalid(['limit']); ->assertInvalid(['limit']);
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidQueryParameterProvider')] #[DataProvider('invalidQueryParameterProvider')]
public function test_authentications_with_invalid_period_returns_validation_error($period) : void public function test_authentications_with_invalid_period_returns_validation_error($period) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class GroupAssignRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -58,9 +55,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -11,6 +11,7 @@
use Mockery; use Mockery;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -28,9 +29,6 @@ class GroupStoreRequestTest extends FeatureTestCase
const UNIQUE_GROUP_NAME = 'MyGroup'; const UNIQUE_GROUP_NAME = 'MyGroup';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -38,9 +36,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -52,9 +48,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -79,9 +73,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
use Tests\TestCase; use Tests\TestCase;
@ -19,9 +20,7 @@ class QrCodeDecodeRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -33,9 +32,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -59,9 +56,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -21,9 +22,7 @@ class SettingStoreRequestTest extends FeatureTestCase
const UNIQUE_KEY = 'UniqueKey'; const UNIQUE_KEY = 'UniqueKey';
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -35,9 +34,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -68,9 +65,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -19,9 +20,7 @@ class SettingUpdateRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -33,9 +32,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -63,9 +60,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class TwoFAccountBatchRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -59,9 +56,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class TwoFAccountDynamicRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input() public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input()
{ {
$twofaccountUriRequest = new TwoFAccountUriRequest(); $twofaccountUriRequest = new TwoFAccountUriRequest();
@ -44,9 +41,7 @@ public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input()
$this->assertEquals($twofaccountUriRequest->rules(), $request->rules()); $this->assertEquals($twofaccountUriRequest->rules(), $request->rules());
} }
/** #[Test]
* @test
*/
public function test_returns_TwoFAccountStoreRequest_rules_otherwise() public function test_returns_TwoFAccountStoreRequest_rules_otherwise()
{ {
$twofaccountStoreRequest = new TwoFAccountStoreRequest(); $twofaccountStoreRequest = new TwoFAccountStoreRequest();

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class TwoFAccountImportRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -56,9 +53,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class TwoFAccountReorderRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -59,9 +56,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -20,9 +21,7 @@ class TwoFAccountStoreRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -34,9 +33,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -110,9 +107,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -20,9 +21,7 @@ class TwoFAccountUpdateRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -34,9 +33,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -86,9 +83,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class TwoFAccountUriRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -63,9 +60,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -6,6 +6,7 @@
use App\Providers\RouteServiceProvider; use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(RouteServiceProvider::class)] #[CoversClass(RouteServiceProvider::class)]
class ThrottlingTest extends FeatureTestCase class ThrottlingTest extends FeatureTestCase
{ {
/** #[Test]
* @test
*/
public function test_api_calls_are_throttled_using_config() public function test_api_calls_are_throttled_using_config()
{ {
/** /**

View File

@ -5,6 +5,7 @@
use App\Console\Commands\CheckDbConnection; use App\Console\Commands\CheckDbConnection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -13,18 +14,14 @@
#[CoversClass(CheckDbConnection::class)] #[CoversClass(CheckDbConnection::class)]
class CheckDbConnectionTest extends FeatureTestCase class CheckDbConnectionTest extends FeatureTestCase
{ {
/** #[Test]
* @test
*/
public function test_CheckDbConnection_ends_successfully() public function test_CheckDbConnection_ends_successfully()
{ {
$this->artisan('2fauth:check-db-connection') $this->artisan('2fauth:check-db-connection')
->assertExitCode(1); ->assertExitCode(1);
} }
/** // #[Test]
* @test
*/
// public function test_CheckDbConnection_without_db_returns_false() // public function test_CheckDbConnection_without_db_returns_false()
// { // {
// DB::shouldReceive('connection', 'getPDO') // DB::shouldReceive('connection', 'getPDO')

View File

@ -6,6 +6,7 @@
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Jackiedo\DotenvEditor\DotenvEditor; use Jackiedo\DotenvEditor\DotenvEditor;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -14,15 +15,13 @@
#[CoversClass(Install::class)] #[CoversClass(Install::class)]
class InstallTest extends FeatureTestCase class InstallTest extends FeatureTestCase
{ {
/**
* @test
*/
const PASSPORT_PENDING_MIGRATIONS_CONFIRMATION = 'Would you like to run all pending database migrations?'; const PASSPORT_PENDING_MIGRATIONS_CONFIRMATION = 'Would you like to run all pending database migrations?';
const PASSPORT_CREATE_CLIENTS_CONFIRMATION = 'Would you like to create the "personal access" and "password grant" clients?'; const PASSPORT_CREATE_CLIENTS_CONFIRMATION = 'Would you like to create the "personal access" and "password grant" clients?';
const TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION = 'Existing .env file found. Do you wish to review its vars?'; const TWOFAUTH_REVIEW_ENV_VAR_CONFIRMATION = 'Existing .env file found. Do you wish to review its vars?';
#[Test]
public function test_install_completes() public function test_install_completes()
{ {
$this->artisan('2fauth:install') $this->artisan('2fauth:install')
@ -35,9 +34,7 @@ public function test_install_completes()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_install_informs_about_no_interaction() public function test_install_informs_about_no_interaction()
{ {
$this->artisan('2fauth:install', ['--no-interaction' => true]) $this->artisan('2fauth:install', ['--no-interaction' => true])
@ -48,9 +45,7 @@ public function test_install_informs_about_no_interaction()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_install_generates_an_app_key() public function test_install_generates_an_app_key()
{ {
config(['app.key' => '']); config(['app.key' => '']);
@ -66,9 +61,7 @@ public function test_install_generates_an_app_key()
$this->assertNotEquals('', config('app.key')); $this->assertNotEquals('', config('app.key'));
} }
/** #[Test]
* @test
*/
public function test_install_gives_2fauth_address() public function test_install_gives_2fauth_address()
{ {
$this->artisan('2fauth:install') $this->artisan('2fauth:install')
@ -79,9 +72,7 @@ public function test_install_gives_2fauth_address()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_install_informs_about_sponsoring() public function test_install_informs_about_sponsoring()
{ {
$this->artisan('2fauth:install') $this->artisan('2fauth:install')
@ -93,9 +84,7 @@ public function test_install_informs_about_sponsoring()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_install_fails_with_exception_message() public function test_install_fails_with_exception_message()
{ {
$mock = $this->mock(DotenvEditor::class); $mock = $this->mock(DotenvEditor::class);
@ -107,9 +96,7 @@ public function test_install_fails_with_exception_message()
->assertFailed(); ->assertFailed();
} }
/** #[Test]
* @test
*/
public function test_install_fails_with_link_to_online_help() public function test_install_fails_with_link_to_online_help()
{ {
$mock = $this->mock(DotenvEditor::class); $mock = $this->mock(DotenvEditor::class);

View File

@ -6,6 +6,7 @@
use App\Models\User; use App\Models\User;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class PurgeLogTest extends FeatureTestCase class PurgeLogTest extends FeatureTestCase
@ -15,9 +16,6 @@ class PurgeLogTest extends FeatureTestCase
*/ */
protected $user; protected $user;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -25,18 +23,14 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_purgeLog_completes() public function test_purgeLog_completes()
{ {
$this->artisan('2fauth:purge-log') $this->artisan('2fauth:purge-log')
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_purgeLog_defaults_to_one_year() 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();
@ -52,9 +46,7 @@ public function test_purgeLog_defaults_to_one_year()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_purgeLog_deletes_records_older_than_retention_time() public function test_purgeLog_deletes_records_older_than_retention_time()
{ {
$retention = 180; $retention = 180;
@ -68,9 +60,7 @@ public function test_purgeLog_deletes_records_older_than_retention_time()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_purgeLog_deletes_logout_only_records_older_than_retention_time() public function test_purgeLog_deletes_logout_only_records_older_than_retention_time()
{ {
$retention = 180; $retention = 180;
@ -85,9 +75,7 @@ public function test_purgeLog_deletes_logout_only_records_older_than_retention_t
]); ]);
} }
/** #[Test]
* @test
*/
public function test_purgeLog_does_not_delete_records_younger_than_retention_time() public function test_purgeLog_does_not_delete_records_younger_than_retention_time()
{ {
$retention = 180; $retention = 180;
@ -101,9 +89,7 @@ public function test_purgeLog_does_not_delete_records_younger_than_retention_tim
]); ]);
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidConfig')] #[DataProvider('provideInvalidConfig')]
public function test_purgeLog_with_invalid_config_defaults_to_one_year($config) public function test_purgeLog_with_invalid_config_defaults_to_one_year($config)
{ {

View File

@ -4,13 +4,12 @@
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class ResetDemoTest extends FeatureTestCase class ResetDemoTest extends FeatureTestCase
{ {
/** #[Test]
* @test
*/
public function test_reset_demo_without_demo_mode_succeeded() public function test_reset_demo_without_demo_mode_succeeded()
{ {
$this->artisan('2fauth:reset-demo') $this->artisan('2fauth:reset-demo')
@ -18,9 +17,7 @@ public function test_reset_demo_without_demo_mode_succeeded()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_reset_demo_succeeded() public function test_reset_demo_succeeded()
{ {
Artisan::call('passport:install', [ Artisan::call('passport:install', [
@ -138,9 +135,7 @@ public function test_reset_demo_succeeded()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_reset_demo_with_invalid_confirmation_succeeded() public function test_reset_demo_with_invalid_confirmation_succeeded()
{ {
Config::set('2fauth.config.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
@ -151,9 +146,7 @@ public function test_reset_demo_with_invalid_confirmation_succeeded()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_reset_demo_with_no_confirm_option_succeeded() public function test_reset_demo_with_no_confirm_option_succeeded()
{ {
Config::set('2fauth.config.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);

View File

@ -3,13 +3,12 @@
namespace Tests\Feature\Console; namespace Tests\Feature\Console;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class ResetTestingTest extends FeatureTestCase class ResetTestingTest extends FeatureTestCase
{ {
/** #[Test]
* @test
*/
public function test_reset_testing_without_testing_mode_succeeded() public function test_reset_testing_without_testing_mode_succeeded()
{ {
$this->artisan('2fauth:reset-testing') $this->artisan('2fauth:reset-testing')
@ -17,9 +16,7 @@ public function test_reset_testing_without_testing_mode_succeeded()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_reset_testing_succeeded() public function test_reset_testing_succeeded()
{ {
Config::set('2fauth.config.isTestingApp', true); Config::set('2fauth.config.isTestingApp', true);
@ -132,9 +129,7 @@ public function test_reset_testing_succeeded()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_reset_testing_with_invalid_confirmation_succeeded() public function test_reset_testing_with_invalid_confirmation_succeeded()
{ {
Config::set('2fauth.config.isTestingApp', true); Config::set('2fauth.config.isTestingApp', true);
@ -145,9 +140,7 @@ public function test_reset_testing_with_invalid_confirmation_succeeded()
->assertSuccessful(); ->assertSuccessful();
} }
/** #[Test]
* @test
*/
public function test_reset_testing_with_no_confirm_option_succeeded() public function test_reset_testing_with_no_confirm_option_succeeded()
{ {
Config::set('2fauth.config.isTestingApp', true); Config::set('2fauth.config.isTestingApp', true);

View File

@ -7,6 +7,7 @@
use App\Services\Auth\ReverseProxyGuard; use App\Services\Auth\ReverseProxyGuard;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -37,9 +38,7 @@ public function test_user_is_retreived_from_db()
$this->assertEquals($dbUser->id, $user->id); $this->assertEquals($dbUser->id, $user->id);
} }
/** #[Test]
* @test
*/
public function test_user_is_set_from_proxy_headers() public function test_user_is_set_from_proxy_headers()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -61,9 +60,7 @@ public function test_user_is_set_from_proxy_headers()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_is_set_from_proxy_headers_with_an_email() public function test_user_is_set_from_proxy_headers_with_an_email()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -87,9 +84,7 @@ public function test_user_is_set_from_proxy_headers_with_an_email()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_is_set_from_proxy_headers_even_if_name_is_long() public function test_user_is_set_from_proxy_headers_even_if_name_is_long()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -116,9 +111,7 @@ public function test_user_is_set_from_proxy_headers_even_if_name_is_long()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_is_not_set_from_proxy_headers_when_name_is_missing() public function test_user_is_not_set_from_proxy_headers_when_name_is_missing()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -137,9 +130,7 @@ public function test_user_is_not_set_from_proxy_headers_when_name_is_missing()
$this->assertDatabaseCount('users', 0); $this->assertDatabaseCount('users', 0);
} }
/** #[Test]
* @test
*/
public function test_user_email_is_synced_with_email_from_proxy_headers() public function test_user_email_is_synced_with_email_from_proxy_headers()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -164,9 +155,7 @@ public function test_user_email_is_synced_with_email_from_proxy_headers()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_missing() public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_missing()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -191,9 +180,7 @@ public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_m
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_invalid() public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_invalid()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -218,9 +205,7 @@ public function test_user_email_is_not_synced_when_email_from_proxy_headers_is_i
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_email_is_not_sync_when_email_from_proxy_headers_is_already_in_use() public function test_user_email_is_not_sync_when_email_from_proxy_headers_is_already_in_use()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');

View File

@ -11,6 +11,7 @@
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -27,9 +28,7 @@ class ForgotPasswordControllerTest extends FeatureTestCase
*/ */
protected $user; protected $user;
/** #[Test]
* @test
*/
public function test_submit_email_password_request_without_email_returns_validation_error() public function test_submit_email_password_request_without_email_returns_validation_error()
{ {
$response = $this->json('POST', '/user/password/lost', [ $response = $this->json('POST', '/user/password/lost', [
@ -40,9 +39,7 @@ public function test_submit_email_password_request_without_email_returns_validat
->assertJsonValidationErrors(['email']); ->assertJsonValidationErrors(['email']);
} }
/** #[Test]
* @test
*/
public function test_submit_email_password_request_with_invalid_email_returns_validation_error() public function test_submit_email_password_request_with_invalid_email_returns_validation_error()
{ {
$response = $this->json('POST', '/user/password/lost', [ $response = $this->json('POST', '/user/password/lost', [
@ -53,9 +50,7 @@ public function test_submit_email_password_request_with_invalid_email_returns_va
->assertJsonValidationErrors(['email']); ->assertJsonValidationErrors(['email']);
} }
/** #[Test]
* @test
*/
public function test_submit_email_password_request_with_unknown_email_returns_validation_error() public function test_submit_email_password_request_with_unknown_email_returns_validation_error()
{ {
$response = $this->json('POST', '/user/password/lost', [ $response = $this->json('POST', '/user/password/lost', [
@ -66,9 +61,7 @@ public function test_submit_email_password_request_with_unknown_email_returns_va
->assertJsonValidationErrors(['email']); ->assertJsonValidationErrors(['email']);
} }
/** #[Test]
* @test
*/
public function test_submit_email_password_request_returns_success() public function test_submit_email_password_request_returns_success()
{ {
Notification::fake(); Notification::fake();
@ -89,9 +82,7 @@ public function test_submit_email_password_request_returns_success()
}); });
} }
/** #[Test]
* @test
*/
public function test_submit_email_password_request_in_demo_mode_returns_unauthorized() public function test_submit_email_password_request_in_demo_mode_returns_unauthorized()
{ {
Config::set('2fauth.config.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
@ -103,9 +94,7 @@ public function test_submit_email_password_request_in_demo_mode_returns_unauthor
$response->assertStatus(401); $response->assertStatus(401);
} }
/** #[Test]
* @test
*/
public function test_submit_email_password_request_when_authenticated_returns_bad_request() public function test_submit_email_password_request_when_authenticated_returns_bad_request()
{ {
/** /**

View File

@ -2,7 +2,10 @@
namespace Tests\Feature\Http\Auth; namespace Tests\Feature\Http\Auth;
use App\Exceptions\Handler;
use App\Http\Controllers\Auth\LoginController; use App\Http\Controllers\Auth\LoginController;
use App\Http\Middleware\KickOutInactiveUser;
use App\Http\Middleware\LogUserLastSeen;
use App\Http\Middleware\RejectIfAuthenticated; use App\Http\Middleware\RejectIfAuthenticated;
use App\Http\Middleware\RejectIfDemoMode; use App\Http\Middleware\RejectIfDemoMode;
use App\Http\Middleware\RejectIfReverseProxy; use App\Http\Middleware\RejectIfReverseProxy;
@ -12,10 +15,13 @@
use App\Models\User; use App\Models\User;
use App\Notifications\FailedLogin; use App\Notifications\FailedLogin;
use App\Notifications\SignedInWithNewDevice; use App\Notifications\SignedInWithNewDevice;
use App\Rules\CaseInsensitiveEmailExists;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -25,9 +31,13 @@
#[CoversClass(RejectIfAuthenticated::class)] #[CoversClass(RejectIfAuthenticated::class)]
#[CoversClass(RejectIfReverseProxy::class)] #[CoversClass(RejectIfReverseProxy::class)]
#[CoversClass(RejectIfDemoMode::class)] #[CoversClass(RejectIfDemoMode::class)]
#[CoversClass(SkipIfAuthenticated::class)]
#[CoversClass(LoginListener::class)] #[CoversClass(LoginListener::class)]
#[CoversClass(FailedLoginListener::class)] #[CoversClass(FailedLoginListener::class)]
#[CoversMethod(CaseInsensitiveEmailExists::class, 'handle')]
#[CoversMethod(SkipIfAuthenticated::class, 'handle')]
#[CoversMethod(Handler::class, 'register')]
#[CoversMethod(KickOutInactiveUser::class, 'handle')]
#[CoversMethod(LogUserLastSeen::class, 'handle')]
class LoginTest extends FeatureTestCase class LoginTest extends FeatureTestCase
{ {
/** /**
@ -44,9 +54,6 @@ class LoginTest extends FeatureTestCase
private const WRONG_PASSWORD = 'wrong_password'; private const WRONG_PASSWORD = 'wrong_password';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -55,9 +62,7 @@ public function setUp() : void
$this->admin = User::factory()->administrator()->create(); $this->admin = User::factory()->administrator()->create();
} }
/** #[Test]
* @test
*/
public function test_user_login_returns_success() public function test_user_login_returns_success()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -77,9 +82,7 @@ public function test_user_login_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_login_send_new_device_notification() public function test_login_send_new_device_notification()
{ {
Notification::fake(); Notification::fake();
@ -107,9 +110,7 @@ public function test_login_send_new_device_notification()
Notification::assertSentTo($this->user, SignedInWithNewDevice::class); Notification::assertSentTo($this->user, SignedInWithNewDevice::class);
} }
/** #[Test]
* @test
*/
public function test_login_does_not_send_new_device_notification() public function test_login_does_not_send_new_device_notification()
{ {
Notification::fake(); Notification::fake();
@ -137,9 +138,7 @@ public function test_login_does_not_send_new_device_notification()
Notification::assertNothingSentTo($this->user); Notification::assertNothingSentTo($this->user);
} }
/** #[Test]
* @test
*/
public function test_admin_login_returns_admin_role() public function test_admin_login_returns_admin_role()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -152,11 +151,7 @@ public function test_admin_login_returns_admin_role()
]); ]);
} }
/** #[Test]
* @test
*
* @covers \App\Rules\CaseInsensitiveEmailExists
*/
public function test_user_login_with_uppercased_email_returns_success() public function test_user_login_with_uppercased_email_returns_success()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -175,11 +170,7 @@ public function test_user_login_with_uppercased_email_returns_success()
]); ]);
} }
/** #[Test]
* @test
*
* @covers \App\Http\Middleware\SkipIfAuthenticated
*/
public function test_user_login_already_authenticated_is_rejected() public function test_user_login_already_authenticated_is_rejected()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -198,9 +189,7 @@ public function test_user_login_already_authenticated_is_rejected()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_login_with_missing_data_returns_validation_error() public function test_user_login_with_missing_data_returns_validation_error()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -214,11 +203,7 @@ public function test_user_login_with_missing_data_returns_validation_error()
]); ]);
} }
/** #[Test]
* @test
*
* @covers \App\Exceptions\Handler
*/
public function test_user_login_with_invalid_credentials_returns_unauthorized() public function test_user_login_with_invalid_credentials_returns_unauthorized()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -231,9 +216,7 @@ public function test_user_login_with_invalid_credentials_returns_unauthorized()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_login_with_invalid_credentials_send_failed_login_notification() public function test_login_with_invalid_credentials_send_failed_login_notification()
{ {
Notification::fake(); Notification::fake();
@ -249,9 +232,7 @@ public function test_login_with_invalid_credentials_send_failed_login_notificati
Notification::assertSentTo($this->user, FailedLogin::class); Notification::assertSentTo($this->user, FailedLogin::class);
} }
/** #[Test]
* @test
*/
public function test_login_with_invalid_credentials_does_not_send_new_device_notification() public function test_login_with_invalid_credentials_does_not_send_new_device_notification()
{ {
Notification::fake(); Notification::fake();
@ -267,9 +248,7 @@ public function test_login_with_invalid_credentials_does_not_send_new_device_not
Notification::assertNothingSentTo($this->user); Notification::assertNothingSentTo($this->user);
} }
/** #[Test]
* @test
*/
public function test_too_many_login_attempts_with_invalid_credentials_returns_too_many_request_error() public function test_too_many_login_attempts_with_invalid_credentials_returns_too_many_request_error()
{ {
$throttle = 8; $throttle = 8;
@ -291,9 +270,7 @@ public function test_too_many_login_attempts_with_invalid_credentials_returns_to
->assertStatus(429); ->assertStatus(429);
} }
/** #[Test]
* @test
*/
public function test_user_logout_returns_validation_success() public function test_user_logout_returns_validation_success()
{ {
$response = $this->json('POST', '/user/login', [ $response = $this->json('POST', '/user/login', [
@ -309,12 +286,7 @@ public function test_user_logout_returns_validation_success()
]); ]);
} }
/** #[Test]
* @test
*
* @covers \App\Http\Middleware\KickOutInactiveUser
* @covers \App\Http\Middleware\LogUserLastSeen
*/
public function test_user_logout_after_inactivity_returns_teapot() public function test_user_logout_after_inactivity_returns_teapot()
{ {
// Set the autolock period to 1 minute // Set the autolock period to 1 minute

View File

@ -5,6 +5,7 @@
use App\Http\Controllers\Auth\PasswordController; use App\Http\Controllers\Auth\PasswordController;
use App\Models\User; use App\Models\User;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -22,9 +23,6 @@ class PasswordControllerTest extends FeatureTestCase
private const NEW_PASSWORD = 'newPassword'; private const NEW_PASSWORD = 'newPassword';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -32,9 +30,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_update_return_success() public function test_update_return_success()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -49,9 +45,7 @@ public function test_update_return_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_passing_bad_current_pwd_return_bad_request() public function test_update_passing_bad_current_pwd_return_bad_request()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -66,9 +60,7 @@ public function test_update_passing_bad_current_pwd_return_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_passing_invalid_data_return_validation_error() public function test_update_passing_invalid_data_return_validation_error()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')

View File

@ -9,6 +9,7 @@
use App\Rules\ComplyWithEmailRestrictionPolicy; use App\Rules\ComplyWithEmailRestrictionPolicy;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -33,17 +34,12 @@ class RegisterControllerTest extends FeatureTestCase
private const EMAIL_FILTERING_RULE = '^[A-Za-z0-9._%+-]+@example\.org'; private const EMAIL_FILTERING_RULE = '^[A-Za-z0-9._%+-]+@example\.org';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
} }
/** #[Test]
* @test
*/
public function test_register_returns_success() public function test_register_returns_success()
{ {
DB::table('users')->delete(); DB::table('users')->delete();
@ -69,9 +65,7 @@ public function test_register_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_register_with_uppercased_email_returns_success() public function test_register_with_uppercased_email_returns_success()
{ {
DB::table('users')->delete(); DB::table('users')->delete();
@ -97,9 +91,7 @@ public function test_register_with_uppercased_email_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_register_with_invalid_data_returns_validation_error() public function test_register_with_invalid_data_returns_validation_error()
{ {
$response = $this->json('POST', '/user', [ $response = $this->json('POST', '/user', [
@ -111,9 +103,7 @@ public function test_register_with_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_register_first_user_only_as_admin() public function test_register_first_user_only_as_admin()
{ {
$this->assertDatabaseCount('users', 0); $this->assertDatabaseCount('users', 0);
@ -142,9 +132,7 @@ public function test_register_first_user_only_as_admin()
$this->assertEquals(1, User::admins()->count()); $this->assertEquals(1, User::admins()->count());
} }
/** #[Test]
* @test
*/
public function test_register_is_forbidden_when_registration_is_disabled() public function test_register_is_forbidden_when_registration_is_disabled()
{ {
Settings::set('disableRegistration', true); Settings::set('disableRegistration', true);
@ -158,9 +146,7 @@ public function test_register_is_forbidden_when_registration_is_disabled()
->assertStatus(403); ->assertStatus(403);
} }
/** #[Test]
* @test
*/
public function test_register_succeeds_when_email_is_in_restricted_list() public function test_register_succeeds_when_email_is_in_restricted_list()
{ {
Settings::set('restrictRegistration', true); Settings::set('restrictRegistration', true);
@ -176,9 +162,7 @@ public function test_register_succeeds_when_email_is_in_restricted_list()
->assertStatus(201); ->assertStatus(201);
} }
/** #[Test]
* @test
*/
public function test_register_fails_when_email_is_not_in_restricted_list() public function test_register_fails_when_email_is_not_in_restricted_list()
{ {
Settings::set('restrictRegistration', true); Settings::set('restrictRegistration', true);
@ -194,9 +178,7 @@ public function test_register_fails_when_email_is_not_in_restricted_list()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_register_succeeds_when_email_matchs_filtering_rule() public function test_register_succeeds_when_email_matchs_filtering_rule()
{ {
Settings::set('restrictRegistration', true); Settings::set('restrictRegistration', true);
@ -212,9 +194,7 @@ public function test_register_succeeds_when_email_matchs_filtering_rule()
->assertStatus(201); ->assertStatus(201);
} }
/** #[Test]
* @test
*/
public function test_register_fails_when_email_does_not_match_filtering_rule() public function test_register_fails_when_email_does_not_match_filtering_rule()
{ {
Settings::set('restrictRegistration', true); Settings::set('restrictRegistration', true);
@ -230,9 +210,7 @@ public function test_register_fails_when_email_does_not_match_filtering_rule()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_register_succeeds_when_email_is_allowed_by_list_over_regex() public function test_register_succeeds_when_email_is_allowed_by_list_over_regex()
{ {
Settings::set('restrictRegistration', true); Settings::set('restrictRegistration', true);
@ -248,9 +226,7 @@ public function test_register_succeeds_when_email_is_allowed_by_list_over_regex(
->assertStatus(201); ->assertStatus(201);
} }
/** #[Test]
* @test
*/
public function test_register_succeeds_when_email_is_allowed_by_regex_over_list() public function test_register_succeeds_when_email_is_allowed_by_regex_over_list()
{ {
Settings::set('restrictRegistration', true); Settings::set('restrictRegistration', true);

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -22,9 +23,7 @@ class ResetPasswordControllerTest extends FeatureTestCase
*/ */
protected $user; protected $user;
/** #[Test]
* @test
*/
public function test_submit_reset_password_without_input_returns_validation_error() public function test_submit_reset_password_without_input_returns_validation_error()
{ {
$response = $this->json('POST', '/user/password/reset', [ $response = $this->json('POST', '/user/password/reset', [
@ -38,9 +37,7 @@ public function test_submit_reset_password_without_input_returns_validation_erro
->assertJsonValidationErrors(['email', 'password', 'token']); ->assertJsonValidationErrors(['email', 'password', 'token']);
} }
/** #[Test]
* @test
*/
public function test_submit_reset_password_with_invalid_data_returns_validation_error() public function test_submit_reset_password_with_invalid_data_returns_validation_error()
{ {
$response = $this->json('POST', '/user/password/reset', [ $response = $this->json('POST', '/user/password/reset', [
@ -54,9 +51,7 @@ public function test_submit_reset_password_with_invalid_data_returns_validation_
->assertJsonValidationErrors(['email', 'password']); ->assertJsonValidationErrors(['email', 'password']);
} }
/** #[Test]
* @test
*/
public function test_submit_reset_password_with_too_short_pwd_returns_validation_error() public function test_submit_reset_password_with_too_short_pwd_returns_validation_error()
{ {
$response = $this->json('POST', '/user/password/reset', [ $response = $this->json('POST', '/user/password/reset', [
@ -70,9 +65,7 @@ public function test_submit_reset_password_with_too_short_pwd_returns_validation
->assertJsonValidationErrors(['password']); ->assertJsonValidationErrors(['password']);
} }
/** #[Test]
* @test
*/
public function test_submit_reset_password_returns_success() public function test_submit_reset_password_returns_success()
{ {
Notification::fake(); Notification::fake();

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Laravel\Socialite\Facades\Socialite; use Laravel\Socialite\Facades\Socialite;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -36,9 +37,6 @@ class SocialiteControllerTest extends FeatureTestCase
private const USER_EMAIL = 'john@provider.com'; private const USER_EMAIL = 'john@provider.com';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -60,9 +58,7 @@ public function setUp() : void
$this->socialiteUser->nickname = self::USER_NICKNAME; $this->socialiteUser->nickname = self::USER_NICKNAME;
} }
/** #[Test]
* @test
*/
public function test_redirect_redirects_to_provider_url() public function test_redirect_redirects_to_provider_url()
{ {
Settings::set('enableSso', true); Settings::set('enableSso', true);
@ -72,9 +68,7 @@ public function test_redirect_redirects_to_provider_url()
$response->assertRedirectContains('https://github.com/login/oauth/authorize'); $response->assertRedirectContains('https://github.com/login/oauth/authorize');
} }
/** #[Test]
* @test
*/
public function test_redirect_returns_error_when_registrations_are_disabled() public function test_redirect_returns_error_when_registrations_are_disabled()
{ {
Settings::set('enableSso', false); Settings::set('enableSso', false);
@ -84,9 +78,7 @@ public function test_redirect_returns_error_when_registrations_are_disabled()
$response->assertRedirect('/error?err=sso_disabled'); $response->assertRedirect('/error?err=sso_disabled');
} }
/** #[Test]
* @test
*/
public function test_callback_authenticates_the_user() public function test_callback_authenticates_the_user()
{ {
Socialite::shouldReceive('driver->user') Socialite::shouldReceive('driver->user')
@ -97,9 +89,7 @@ public function test_callback_authenticates_the_user()
$this->assertAuthenticatedAs($this->user, 'web-guard'); $this->assertAuthenticatedAs($this->user, 'web-guard');
} }
/** #[Test]
* @test
*/
public function test_callback_redirects_authenticated_user_to_accounts() public function test_callback_redirects_authenticated_user_to_accounts()
{ {
Socialite::shouldReceive('driver->user') Socialite::shouldReceive('driver->user')
@ -110,9 +100,7 @@ public function test_callback_redirects_authenticated_user_to_accounts()
$response->assertRedirect('/accounts'); $response->assertRedirect('/accounts');
} }
/** #[Test]
* @test
*/
public function test_callback_updates_user_informations() public function test_callback_updates_user_informations()
{ {
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User; $socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
@ -132,9 +120,7 @@ public function test_callback_updates_user_informations()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_updates_username_with_fallback_value() public function test_callback_updates_username_with_fallback_value()
{ {
$socialiteUpdatedUser = new \Laravel\Socialite\Two\User; $socialiteUpdatedUser = new \Laravel\Socialite\Two\User;
@ -154,9 +140,7 @@ public function test_callback_updates_username_with_fallback_value()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_registers_new_user() public function test_callback_registers_new_user()
{ {
$newSocialiteUser = new \Laravel\Socialite\Two\User; $newSocialiteUser = new \Laravel\Socialite\Two\User;
@ -177,9 +161,7 @@ public function test_callback_registers_new_user()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_registers_new_user_with_existing_name() public function test_callback_registers_new_user_with_existing_name()
{ {
$socialiteUserWithSameName = new \Laravel\Socialite\Two\User; $socialiteUserWithSameName = new \Laravel\Socialite\Two\User;
@ -200,9 +182,7 @@ public function test_callback_registers_new_user_with_existing_name()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_always_registers_first_user_as_admin() public function test_callback_always_registers_first_user_as_admin()
{ {
DB::table('users')->delete(); DB::table('users')->delete();
@ -221,9 +201,7 @@ public function test_callback_always_registers_first_user_as_admin()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_returns_error_when_email_is_already_used() public function test_callback_returns_error_when_email_is_already_used()
{ {
$userWithSameEmail = User::factory()->create([ $userWithSameEmail = User::factory()->create([
@ -250,9 +228,7 @@ public function test_callback_returns_error_when_email_is_already_used()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_redirects_to_error_when_registrations_are_closed() public function test_callback_redirects_to_error_when_registrations_are_closed()
{ {
Settings::set('disableRegistration', true); Settings::set('disableRegistration', true);
@ -271,9 +247,7 @@ public function test_callback_redirects_to_error_when_registrations_are_closed()
$response->assertRedirect('/error?err=sso_no_register'); $response->assertRedirect('/error?err=sso_no_register');
} }
/** #[Test]
* @test
*/
public function test_callback_skips_registration_when_all_registrations_are_closed() public function test_callback_skips_registration_when_all_registrations_are_closed()
{ {
Settings::set('disableRegistration', true); Settings::set('disableRegistration', true);
@ -295,9 +269,7 @@ public function test_callback_skips_registration_when_all_registrations_are_clos
]); ]);
} }
/** #[Test]
* @test
*/
public function test_callback_registers_new_user_when_sso_registrations_are_enabled() public function test_callback_registers_new_user_when_sso_registrations_are_enabled()
{ {
Settings::set('disableRegistration', true); Settings::set('disableRegistration', true);

View File

@ -10,6 +10,7 @@
use App\Policies\UserPolicy; use App\Policies\UserPolicy;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -33,9 +34,6 @@ class UserControllerTest extends FeatureTestCase
private const PASSWORD = 'password'; private const PASSWORD = 'password';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -43,9 +41,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_update_user_returns_success() public function test_update_user_returns_success()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -73,9 +69,7 @@ public function test_update_user_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_user_without_changing_email_returns_success() public function test_update_user_without_changing_email_returns_success()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -100,9 +94,7 @@ public function test_update_user_without_changing_email_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_user_without_changing_name_returns_success() public function test_update_user_without_changing_name_returns_success()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -127,9 +119,7 @@ public function test_update_user_without_changing_name_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_user_with_uppercased_email_returns_success() public function test_update_user_with_uppercased_email_returns_success()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -154,9 +144,7 @@ public function test_update_user_with_uppercased_email_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_user_in_demo_mode_returns_unchanged_user() public function test_update_user_in_demo_mode_returns_unchanged_user()
{ {
Config::set('2fauth.config.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
@ -185,9 +173,7 @@ public function test_update_user_in_demo_mode_returns_unchanged_user()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_user_passing_wrong_password_returns_bad_request() public function test_update_user_passing_wrong_password_returns_bad_request()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -199,9 +185,7 @@ public function test_update_user_passing_wrong_password_returns_bad_request()
->assertStatus(400); ->assertStatus(400);
} }
/** #[Test]
* @test
*/
public function test_update_user_with_invalid_data_returns_validation_error() public function test_update_user_with_invalid_data_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -213,9 +197,7 @@ public function test_update_user_with_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_delete_user_returns_success() public function test_delete_user_returns_success()
{ {
$this->actingAs($this->user, 'web-guard') $this->actingAs($this->user, 'web-guard')
@ -225,9 +207,7 @@ public function test_delete_user_returns_success()
->assertNoContent(); ->assertNoContent();
} }
/** #[Test]
* @test
*/
public function test_delete_user_in_demo_mode_returns_unauthorized() public function test_delete_user_in_demo_mode_returns_unauthorized()
{ {
Config::set('2fauth.config.isDemoApp', true); Config::set('2fauth.config.isDemoApp', true);
@ -246,9 +226,7 @@ public function test_delete_user_in_demo_mode_returns_unauthorized()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_delete_user_passing_wrong_password_returns_bad_request() public function test_delete_user_passing_wrong_password_returns_bad_request()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -262,9 +240,7 @@ public function test_delete_user_passing_wrong_password_returns_bad_request()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_delete_the_only_admin_returns_bad_request() public function test_delete_the_only_admin_returns_bad_request()
{ {
/** /**

View File

@ -8,9 +8,12 @@
use App\Models\User; use App\Models\User;
use App\Notifications\WebauthnRecoveryNotification; use App\Notifications\WebauthnRecoveryNotification;
use App\Providers\AuthServiceProvider; use App\Providers\AuthServiceProvider;
use App\Rules\CaseInsensitiveEmailExists;
use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -21,6 +24,7 @@
#[CoversClass(WebauthnCredentialBroker::class)] #[CoversClass(WebauthnCredentialBroker::class)]
#[CoversClass(WebauthnDeviceLostRequest::class)] #[CoversClass(WebauthnDeviceLostRequest::class)]
#[CoversClass(AuthServiceProvider::class)] #[CoversClass(AuthServiceProvider::class)]
#[CoversMethod(CaseInsensitiveEmailExists::class, 'validate')]
class WebAuthnDeviceLostControllerTest extends FeatureTestCase class WebAuthnDeviceLostControllerTest extends FeatureTestCase
{ {
/** /**
@ -28,9 +32,6 @@ class WebAuthnDeviceLostControllerTest extends FeatureTestCase
*/ */
protected $user; protected $user;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -38,11 +39,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*
* @covers \App\Models\Traits\WebAuthnManageCredentials
*/
public function test_sendRecoveryEmail_sends_notification_on_success() public function test_sendRecoveryEmail_sends_notification_on_success()
{ {
Notification::fake(); Notification::fake();
@ -63,9 +60,7 @@ public function test_sendRecoveryEmail_sends_notification_on_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_WebauthnRecoveryNotification_renders_to_email() public function test_WebauthnRecoveryNotification_renders_to_email()
{ {
$mail = (new WebauthnRecoveryNotification('test_token'))->toMail($this->user)->render(); $mail = (new WebauthnRecoveryNotification('test_token'))->toMail($this->user)->render();
@ -101,9 +96,7 @@ public function test_WebauthnRecoveryNotification_renders_to_email()
); );
} }
/** #[Test]
* @test
*/
public function test_sendRecoveryEmail_does_not_send_anything_to_unknown_email() public function test_sendRecoveryEmail_does_not_send_anything_to_unknown_email()
{ {
Notification::fake(); Notification::fake();
@ -124,9 +117,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_unknown_email()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_sendRecoveryEmail_does_not_send_anything_to_invalid_email() public function test_sendRecoveryEmail_does_not_send_anything_to_invalid_email()
{ {
Notification::fake(); Notification::fake();
@ -147,9 +138,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_invalid_email()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_sendRecoveryEmail_does_not_send_anything_to_not_WebAuthnAuthenticatable() public function test_sendRecoveryEmail_does_not_send_anything_to_not_WebAuthnAuthenticatable()
{ {
$mock = $this->mock(\App\Extensions\WebauthnCredentialBroker::class)->makePartial(); $mock = $this->mock(\App\Extensions\WebauthnCredentialBroker::class)->makePartial();
@ -170,9 +159,7 @@ public function test_sendRecoveryEmail_does_not_send_anything_to_not_WebAuthnAut
]); ]);
} }
/** #[Test]
* @test
*/
public function test_sendRecoveryEmail_is_throttled() public function test_sendRecoveryEmail_is_throttled()
{ {
Notification::fake(); Notification::fake();
@ -202,9 +189,7 @@ public function test_sendRecoveryEmail_is_throttled()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_error_if_no_broker_is_set() public function test_error_if_no_broker_is_set()
{ {
$this->app['config']->set('auth.passwords.webauthn', null); $this->app['config']->set('auth.passwords.webauthn', null);

View File

@ -4,12 +4,15 @@
use App\Extensions\WebauthnTwoFAuthUserProvider; use App\Extensions\WebauthnTwoFAuthUserProvider;
use App\Http\Controllers\Auth\WebAuthnLoginController; use App\Http\Controllers\Auth\WebAuthnLoginController;
use App\Http\Middleware\SkipIfAuthenticated;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Laragear\WebAuthn\Assertion\Validator\AssertionValidator; use Laragear\WebAuthn\Assertion\Validator\AssertionValidator;
use Laragear\WebAuthn\Enums\UserVerification; use Laragear\WebAuthn\Enums\UserVerification;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -18,6 +21,7 @@
#[CoversClass(WebAuthnLoginController::class)] #[CoversClass(WebAuthnLoginController::class)]
#[CoversClass(User::class)] #[CoversClass(User::class)]
#[CoversClass(WebauthnTwoFAuthUserProvider::class)] #[CoversClass(WebauthnTwoFAuthUserProvider::class)]
#[CoversMethod(SkipIfAuthenticated::class, 'handle')]
class WebAuthnLoginControllerTest extends FeatureTestCase class WebAuthnLoginControllerTest extends FeatureTestCase
{ {
/** /**
@ -85,9 +89,6 @@ class WebAuthnLoginControllerTest extends FeatureTestCase
const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA=='; const ASSERTION_CHALLENGE = 'iXozmynKi+YD2iRvKNbSPA==';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -95,9 +96,7 @@ public function setUp() : void
DB::table('users')->delete(); DB::table('users')->delete();
} }
/** #[Test]
* @test
*/
public function test_webauthn_login_returns_success() public function test_webauthn_login_returns_success()
{ {
$this->user = User::factory()->create(['email' => self::EMAIL]); $this->user = User::factory()->create(['email' => self::EMAIL]);
@ -141,9 +140,7 @@ public function test_webauthn_login_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_webauthn_admin_login_returns_admin_role() public function test_webauthn_admin_login_returns_admin_role()
{ {
$this->admin = User::factory()->administrator()->create(['email' => self::EMAIL]); $this->admin = User::factory()->administrator()->create(['email' => self::EMAIL]);
@ -180,9 +177,7 @@ public function test_webauthn_admin_login_returns_admin_role()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_webauthn_login_merge_handle_if_missing() public function test_webauthn_login_merge_handle_if_missing()
{ {
$this->user = User::factory()->create(['email' => self::EMAIL]); $this->user = User::factory()->create(['email' => self::EMAIL]);
@ -225,9 +220,7 @@ public function test_webauthn_login_merge_handle_if_missing()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_legacy_login_is_rejected_when_webauthn_only_is_enable() public function test_legacy_login_is_rejected_when_webauthn_only_is_enable()
{ {
$this->user = User::factory()->create([ $this->user = User::factory()->create([
@ -245,11 +238,7 @@ public function test_legacy_login_is_rejected_when_webauthn_only_is_enable()
->assertUnauthorized(); ->assertUnauthorized();
} }
/** #[Test]
* @test
*
* @covers \App\Http\Middleware\SkipIfAuthenticated
*/
public function test_webauthn_login_already_authenticated_is_rejected() public function test_webauthn_login_already_authenticated_is_rejected()
{ {
$this->user = User::factory()->create(['email' => self::EMAIL]); $this->user = User::factory()->create(['email' => self::EMAIL]);
@ -289,9 +278,7 @@ public function test_webauthn_login_already_authenticated_is_rejected()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_webauthn_login_with_missing_data_returns_validation_error() public function test_webauthn_login_with_missing_data_returns_validation_error()
{ {
$this->user = User::factory()->create(['email' => self::EMAIL]); $this->user = User::factory()->create(['email' => self::EMAIL]);
@ -320,9 +307,7 @@ public function test_webauthn_login_with_missing_data_returns_validation_error()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_webauthn_invalid_login_returns_unauthorized() public function test_webauthn_invalid_login_returns_unauthorized()
{ {
$this->user = User::factory()->create(['email' => self::EMAIL]); $this->user = User::factory()->create(['email' => self::EMAIL]);
@ -337,9 +322,7 @@ public function test_webauthn_invalid_login_returns_unauthorized()
->assertUnauthorized(); ->assertUnauthorized();
} }
/** #[Test]
* @test
*/
public function test_too_many_invalid_login_attempts_returns_too_many_request_error() public function test_too_many_invalid_login_attempts_returns_too_many_request_error()
{ {
$throttle = 8; $throttle = 8;
@ -364,9 +347,7 @@ public function test_too_many_invalid_login_attempts_returns_too_many_request_er
->assertStatus(429); ->assertStatus(429);
} }
/** #[Test]
* @test
*/
public function test_get_options_returns_success() public function test_get_options_returns_success()
{ {
Config::set('webauthn.user_verification', UserVerification::PREFERRED); Config::set('webauthn.user_verification', UserVerification::PREFERRED);
@ -404,9 +385,7 @@ public function test_get_options_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_options_for_securelogin_returns_required_userVerification() public function test_get_options_for_securelogin_returns_required_userVerification()
{ {
Config::set('webauthn.user_verification', UserVerification::REQUIRED); Config::set('webauthn.user_verification', UserVerification::REQUIRED);
@ -446,9 +425,7 @@ public function test_get_options_for_securelogin_returns_required_userVerificati
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_options_for_fastlogin_returns_discouraged_userVerification() public function test_get_options_for_fastlogin_returns_discouraged_userVerification()
{ {
Config::set('webauthn.user_verification', UserVerification::DISCOURAGED); Config::set('webauthn.user_verification', UserVerification::DISCOURAGED);
@ -488,9 +465,7 @@ public function test_get_options_for_fastlogin_returns_discouraged_userVerificat
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_options_with_capitalized_email_returns_success() public function test_get_options_with_capitalized_email_returns_success()
{ {
$this->user = User::factory()->create(['email' => self::EMAIL]); $this->user = User::factory()->create(['email' => self::EMAIL]);
@ -501,9 +476,7 @@ public function test_get_options_with_capitalized_email_returns_success()
->assertOk(); ->assertOk();
} }
/** #[Test]
* @test
*/
public function test_get_options_with_missing_email_returns_validation_errors() public function test_get_options_with_missing_email_returns_validation_errors()
{ {
$this->json('POST', '/webauthn/login/options', [ $this->json('POST', '/webauthn/login/options', [
@ -515,9 +488,7 @@ public function test_get_options_with_missing_email_returns_validation_errors()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_options_with_invalid_email_returns_validation_errors() public function test_get_options_with_invalid_email_returns_validation_errors()
{ {
$this->json('POST', '/webauthn/login/options', [ $this->json('POST', '/webauthn/login/options', [
@ -529,9 +500,7 @@ public function test_get_options_with_invalid_email_returns_validation_errors()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_get_options_with_unknown_email_returns_validation_errors() public function test_get_options_with_unknown_email_returns_validation_errors()
{ {
$this->json('POST', '/webauthn/login/options', [ $this->json('POST', '/webauthn/login/options', [

View File

@ -9,6 +9,7 @@
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -30,9 +31,6 @@ class WebAuthnManageControllerTest extends FeatureTestCase
public const CREDENTIAL_ID_RAW = '+VOLFKPY+/FuMI/sJ7gMllK76L3VoRUINj6lL/Z3qDg='; public const CREDENTIAL_ID_RAW = '+VOLFKPY+/FuMI/sJ7gMllK76L3VoRUINj6lL/Z3qDg=';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -40,9 +38,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_index_returns_success_with_credentials() public function test_index_returns_success_with_credentials()
{ {
DB::table('webauthn_credentials')->insert([ DB::table('webauthn_credentials')->insert([
@ -71,9 +67,7 @@ public function test_index_returns_success_with_credentials()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_rename_returns_success_with_new_name() public function test_rename_returns_success_with_new_name()
{ {
DB::table('webauthn_credentials')->insert([ DB::table('webauthn_credentials')->insert([
@ -102,9 +96,7 @@ public function test_rename_returns_success_with_new_name()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_rename_invalid_data_returns_validation_error() public function test_rename_invalid_data_returns_validation_error()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -114,9 +106,7 @@ public function test_rename_invalid_data_returns_validation_error()
->assertStatus(422); ->assertStatus(422);
} }
/** #[Test]
* @test
*/
public function test_rename_missing_credential_returns_not_found() public function test_rename_missing_credential_returns_not_found()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')
@ -129,9 +119,7 @@ public function test_rename_missing_credential_returns_not_found()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_index_as_reverse_proxy_returns_error() public function test_index_as_reverse_proxy_returns_error()
{ {
$response = $this->actingAs($this->user, 'reverse-proxy-guard') $response = $this->actingAs($this->user, 'reverse-proxy-guard')
@ -139,9 +127,7 @@ public function test_index_as_reverse_proxy_returns_error()
->assertStatus(405); ->assertStatus(405);
} }
/** #[Test]
* @test
*/
public function test_rename_as_reverse_proxy_returns_error() public function test_rename_as_reverse_proxy_returns_error()
{ {
$response = $this->actingAs($this->user, 'reverse-proxy-guard') $response = $this->actingAs($this->user, 'reverse-proxy-guard')
@ -149,9 +135,7 @@ public function test_rename_as_reverse_proxy_returns_error()
->assertStatus(405); ->assertStatus(405);
} }
/** #[Test]
* @test
*/
public function test_delete_as_reverse_proxy_returns_error() public function test_delete_as_reverse_proxy_returns_error()
{ {
$response = $this->actingAs($this->user, 'reverse-proxy-guard') $response = $this->actingAs($this->user, 'reverse-proxy-guard')
@ -159,9 +143,7 @@ public function test_delete_as_reverse_proxy_returns_error()
->assertStatus(405); ->assertStatus(405);
} }
/** #[Test]
* @test
*/
public function test_delete_returns_no_content() public function test_delete_returns_no_content()
{ {
$response = $this->actingAs($this->user, 'web-guard') $response = $this->actingAs($this->user, 'web-guard')

View File

@ -11,6 +11,7 @@
use Illuminate\Support\Facades\Date; use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -35,9 +36,6 @@ class WebAuthnRecoveryControllerTest extends FeatureTestCase
const CREDENTIAL_ID = '-VOLFKPY-_FuMI_sJ7gMllK76L3VoRUINj6lL_Z3qDg'; const CREDENTIAL_ID = '-VOLFKPY-_FuMI_sJ7gMllK76L3VoRUINj6lL_Z3qDg';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -53,9 +51,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_recover_fails_if_no_recovery_is_set() public function test_recover_fails_if_no_recovery_is_set()
{ {
DB::table(config('auth.passwords.webauthn.table'))->delete(); DB::table(config('auth.passwords.webauthn.table'))->delete();
@ -69,9 +65,7 @@ public function test_recover_fails_if_no_recovery_is_set()
->assertJsonValidationErrors('token'); ->assertJsonValidationErrors('token');
} }
/** #[Test]
* @test
*/
public function test_recover_with_wrong_token_returns_validation_error() public function test_recover_with_wrong_token_returns_validation_error()
{ {
$response = $this->json('POST', '/webauthn/recover', [ $response = $this->json('POST', '/webauthn/recover', [
@ -84,9 +78,7 @@ public function test_recover_with_wrong_token_returns_validation_error()
->assertJsonValidationErrors('token'); ->assertJsonValidationErrors('token');
} }
/** #[Test]
* @test
*/
public function test_recover_with_expired_token_returns_validation_error() public function test_recover_with_expired_token_returns_validation_error()
{ {
Date::setTestNow($now = Date::create(2020, 01, 01, 16, 30)); Date::setTestNow($now = Date::create(2020, 01, 01, 16, 30));
@ -107,9 +99,7 @@ public function test_recover_with_expired_token_returns_validation_error()
->assertJsonValidationErrors('token'); ->assertJsonValidationErrors('token');
} }
/** #[Test]
* @test
*/
public function test_recover_with_invalid_password_returns_authentication_error() public function test_recover_with_invalid_password_returns_authentication_error()
{ {
$this->json('POST', '/webauthn/recover', [ $this->json('POST', '/webauthn/recover', [
@ -120,9 +110,7 @@ public function test_recover_with_invalid_password_returns_authentication_error(
->assertStatus(401); ->assertStatus(401);
} }
/** #[Test]
* @test
*/
public function test_recover_returns_validation_error_when_no_user_exists() public function test_recover_returns_validation_error_when_no_user_exists()
{ {
$this->json('POST', '/webauthn/recover', [ $this->json('POST', '/webauthn/recover', [
@ -136,9 +124,7 @@ public function test_recover_returns_validation_error_when_no_user_exists()
->assertJsonValidationErrors('email'); ->assertJsonValidationErrors('email');
} }
/** #[Test]
* @test
*/
public function test_recover_returns_success() public function test_recover_returns_success()
{ {
$response = $this->json('POST', '/webauthn/recover', [ $response = $this->json('POST', '/webauthn/recover', [
@ -153,9 +139,7 @@ public function test_recover_returns_success()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_recover_resets_useWebauthnOnly_user_preference() public function test_recover_resets_useWebauthnOnly_user_preference()
{ {
$this->user['preferences->useWebauthnOnly'] = true; $this->user['preferences->useWebauthnOnly'] = true;
@ -173,9 +157,7 @@ public function test_recover_resets_useWebauthnOnly_user_preference()
$this->assertFalse($this->user->preferences['useWebauthnOnly']); $this->assertFalse($this->user->preferences['useWebauthnOnly']);
} }
/** #[Test]
* @test
*/
public function test_revoke_all_credentials_clear_registered_credentials() public function test_revoke_all_credentials_clear_registered_credentials()
{ {
DB::table('webauthn_credentials')->insert([ DB::table('webauthn_credentials')->insert([

View File

@ -10,6 +10,7 @@
use Laragear\WebAuthn\Http\Requests\AttestedRequest; use Laragear\WebAuthn\Http\Requests\AttestedRequest;
use Laragear\WebAuthn\JsonTransport; use Laragear\WebAuthn\JsonTransport;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -23,9 +24,6 @@ class WebAuthnRegisterControllerTest extends FeatureTestCase
*/ */
protected $user; protected $user;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -33,9 +31,7 @@ public function setUp() : void
$this->user = User::factory()->create(); $this->user = User::factory()->create();
} }
/** #[Test]
* @test
*/
public function test_uses_attestation_with_fastRegistration_request() : void public function test_uses_attestation_with_fastRegistration_request() : void
{ {
Config::set('webauthn.user_verification', UserVerification::DISCOURAGED); Config::set('webauthn.user_verification', UserVerification::DISCOURAGED);
@ -50,9 +46,7 @@ public function test_uses_attestation_with_fastRegistration_request() : void
->assertOk(); ->assertOk();
} }
/** #[Test]
* @test
*/
public function test_uses_attestation_with_secureRegistration_request() : void public function test_uses_attestation_with_secureRegistration_request() : void
{ {
Config::set('webauthn.user_verification', UserVerification::REQUIRED); Config::set('webauthn.user_verification', UserVerification::REQUIRED);
@ -67,9 +61,7 @@ public function test_uses_attestation_with_secureRegistration_request() : void
->assertOk(); ->assertOk();
} }
/** #[Test]
* @test
*/
public function test_register_uses_attested_request() : void public function test_register_uses_attested_request() : void
{ {
$request = $this->mock(AttestedRequest::class); $request = $this->mock(AttestedRequest::class);

View File

@ -6,13 +6,12 @@
use App\Models\User; use App\Models\User;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class AdminOnlyMiddlewareTest extends FeatureTestCase class AdminOnlyMiddlewareTest extends FeatureTestCase
{ {
/** #[Test]
* @test
*/
public function test_users_are_rejected() public function test_users_are_rejected()
{ {
$this->expectException(AuthorizationException::class); $this->expectException(AuthorizationException::class);
@ -31,9 +30,7 @@ public function test_users_are_rejected()
}); });
} }
/** #[Test]
* @test
*/
public function test_admins_pass() public function test_admins_pass()
{ {
/** /**

View File

@ -3,6 +3,7 @@
namespace Tests\Feature\Http\Middlewares; namespace Tests\Feature\Http\Middlewares;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class AuthenticateMiddlewareTest extends FeatureTestCase class AuthenticateMiddlewareTest extends FeatureTestCase
@ -11,9 +12,7 @@ class AuthenticateMiddlewareTest extends FeatureTestCase
private const USER_EMAIL = 'john@example.com'; private const USER_EMAIL = 'john@example.com';
/** #[Test]
* @test
*/
public function test_it_always_authenticates_with_reverse_proxy_guard() public function test_it_always_authenticates_with_reverse_proxy_guard()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -24,9 +23,7 @@ public function test_it_always_authenticates_with_reverse_proxy_guard()
$this->assertAuthenticated('reverse-proxy-guard'); $this->assertAuthenticated('reverse-proxy-guard');
} }
/** #[Test]
* @test
*/
public function test_it_does_not_authenticate_with_empty_header() public function test_it_does_not_authenticate_with_empty_header()
{ {
Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER');
@ -40,9 +37,7 @@ public function test_it_does_not_authenticate_with_empty_header()
])->assertStatus(407); ])->assertStatus(407);
} }
/** #[Test]
* @test
*/
public function test_it_does_not_authenticate_with_missing_header() public function test_it_does_not_authenticate_with_missing_header()
{ {
$this->app['auth']->shouldUse('reverse-proxy-guard'); $this->app['auth']->shouldUse('reverse-proxy-guard');

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -18,9 +19,7 @@ class LoginRequestTest extends FeatureTestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
$request = new LoginRequest(); $request = new LoginRequest();
@ -28,9 +27,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -61,9 +58,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -18,9 +19,7 @@ class UserDeleteRequestTest extends FeatureTestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -56,9 +53,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class UserPatchPwdRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -58,9 +55,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -18,9 +19,7 @@ class UserStoreRequestTest extends FeatureTestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
$request = new UserStoreRequest(); $request = new UserStoreRequest();
@ -28,9 +27,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -66,9 +63,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -10,6 +10,7 @@
use Mockery; use Mockery;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -20,9 +21,7 @@ class UserUpdateRequestTest extends FeatureTestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -34,9 +33,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -81,9 +78,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -17,9 +18,7 @@ class WebauthnAssertedRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -50,9 +49,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@ class WebauthnRenameRequestTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_user_is_authorized() public function test_user_is_authorized()
{ {
Auth::shouldReceive('check') Auth::shouldReceive('check')
@ -32,9 +31,7 @@ public function test_user_is_authorized()
$this->assertTrue($request->authorize()); $this->assertTrue($request->authorize());
} }
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -56,9 +53,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Lang; use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -26,9 +27,6 @@ class SystemControllerTest extends FeatureTestCase
protected $admin; protected $admin;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -37,18 +35,14 @@ public function setUp() : void
$this->admin = User::factory()->administrator()->create(); $this->admin = User::factory()->administrator()->create();
} }
/** #[Test]
* @test
*/
public function test_infos_returns_unauthorized() public function test_infos_returns_unauthorized()
{ {
$response = $this->json('GET', '/system/infos') $response = $this->json('GET', '/system/infos')
->assertUnauthorized(); ->assertUnauthorized();
} }
/** #[Test]
* @test
*/
public function test_infos_returns_forbidden() public function test_infos_returns_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -56,9 +50,7 @@ public function test_infos_returns_forbidden()
->assertForbidden(); ->assertForbidden();
} }
/** #[Test]
* @test
*/
public function test_infos_returns_only_base_collection() public function test_infos_returns_only_base_collection()
{ {
$response = $this->actingAs($this->admin, 'api-guard') $response = $this->actingAs($this->admin, 'api-guard')
@ -87,9 +79,7 @@ public function test_infos_returns_only_base_collection()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy() public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy()
{ {
$response = $this->actingAs($this->admin, 'reverse-proxy-guard') $response = $this->actingAs($this->admin, 'reverse-proxy-guard')
@ -104,9 +94,7 @@ public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy(
]); ]);
} }
/** #[Test]
* @test
*/
public function test_latestrelease_runs_manual_scan() public function test_latestrelease_runs_manual_scan()
{ {
$releaseRadarService = $this->mock(ReleaseRadarService::class)->makePartial(); $releaseRadarService = $this->mock(ReleaseRadarService::class)->makePartial();
@ -121,9 +109,7 @@ public function test_latestrelease_runs_manual_scan()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_testEmail_sends_a_notification() public function test_testEmail_sends_a_notification()
{ {
Notification::fake(); Notification::fake();
@ -136,9 +122,7 @@ public function test_testEmail_sends_a_notification()
Notification::assertSentTo($this->admin, TestEmailSettingNotification::class); Notification::assertSentTo($this->admin, TestEmailSettingNotification::class);
} }
/** #[Test]
* @test
*/
public function test_testEmail_renders_to_email() public function test_testEmail_renders_to_email()
{ {
$mail = (new TestEmailSettingNotification('test_token'))->toMail($this->user)->render(); $mail = (new TestEmailSettingNotification('test_token'))->toMail($this->user)->render();
@ -149,18 +133,14 @@ public function test_testEmail_renders_to_email()
); );
} }
/** #[Test]
* @test
*/
public function test_testEmail_returns_unauthorized() public function test_testEmail_returns_unauthorized()
{ {
$response = $this->json('GET', '/system/infos') $response = $this->json('GET', '/system/infos')
->assertUnauthorized(); ->assertUnauthorized();
} }
/** #[Test]
* @test
*/
public function test_testEmail_returns_forbidden() public function test_testEmail_returns_forbidden()
{ {
$response = $this->actingAs($this->user, 'api-guard') $response = $this->actingAs($this->user, 'api-guard')
@ -168,9 +148,7 @@ public function test_testEmail_returns_forbidden()
->assertForbidden(); ->assertForbidden();
} }
/** #[Test]
* @test
*/
public function test_clearCache_returns_success() public function test_clearCache_returns_success()
{ {
$response = $this->json('GET', '/system/clear-cache'); $response = $this->json('GET', '/system/clear-cache');
@ -178,9 +156,7 @@ public function test_clearCache_returns_success()
$response->assertStatus(200); $response->assertStatus(200);
} }
/** #[Test]
* @test
*/
public function test_optimize_returns_success() public function test_optimize_returns_success()
{ {
$response = $this->json('GET', '/system/optimize'); $response = $this->json('GET', '/system/optimize');

View File

@ -11,6 +11,7 @@
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\Data\HttpRequestTestData; use Tests\Data\HttpRequestTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -42,9 +43,6 @@ class TwoFAccountModelTest extends FeatureTestCase
*/ */
protected $helpers; protected $helpers;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -92,9 +90,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_fill_with_custom_totp_uri_returns_correct_value() public function test_fill_with_custom_totp_uri_returns_correct_value()
{ {
$file = (new FileFactory)->image('file.png', 10, 10); $file = (new FileFactory)->image('file.png', 10, 10);
@ -125,9 +121,7 @@ public function test_fill_with_custom_totp_uri_returns_correct_value()
Storage::disk('imagesLink')->assertMissing($twofaccount->icon); Storage::disk('imagesLink')->assertMissing($twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_fill_with_basic_totp_uri_returns_default_value() public function test_fill_with_basic_totp_uri_returns_default_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -145,9 +139,7 @@ public function test_fill_with_basic_totp_uri_returns_default_value()
$this->assertEquals(null, $twofaccount->icon); $this->assertEquals(null, $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_fill_with_ms_corporate_totp_uri_returns_correct_value() public function test_fill_with_ms_corporate_totp_uri_returns_correct_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -164,9 +156,7 @@ public function test_fill_with_ms_corporate_totp_uri_returns_correct_value()
$this->assertEquals(OtpTestData::ALGORITHM_DEFAULT, $twofaccount->algorithm); $this->assertEquals(OtpTestData::ALGORITHM_DEFAULT, $twofaccount->algorithm);
} }
/** #[Test]
* @test
*/
public function test_fill_with_custom_hotp_uri_returns_correct_value() public function test_fill_with_custom_hotp_uri_returns_correct_value()
{ {
$file = (new FileFactory)->image('file.png', 10, 10); $file = (new FileFactory)->image('file.png', 10, 10);
@ -197,9 +187,7 @@ public function test_fill_with_custom_hotp_uri_returns_correct_value()
Storage::disk('imagesLink')->assertMissing($twofaccount->icon); Storage::disk('imagesLink')->assertMissing($twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_fill_with_basic_hotp_uri_returns_default_value() public function test_fill_with_basic_hotp_uri_returns_default_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -217,9 +205,7 @@ public function test_fill_with_basic_hotp_uri_returns_default_value()
$this->assertEquals(null, $twofaccount->icon); $this->assertEquals(null, $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_filled_with_uri_persists_correct_values_to_db() public function test_filled_with_uri_persists_correct_values_to_db()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -240,9 +226,7 @@ public function test_filled_with_uri_persists_correct_values_to_db()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_fill_with_invalid_uri_returns_ValidationException() public function test_fill_with_invalid_uri_returns_ValidationException()
{ {
$this->expectException(\Illuminate\Validation\ValidationException::class); $this->expectException(\Illuminate\Validation\ValidationException::class);
@ -250,9 +234,7 @@ public function test_fill_with_invalid_uri_returns_ValidationException()
$twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI); $twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI);
} }
/** #[Test]
* @test
*/
public function test_fill_with_invalid_uri_with_mismatching_issuer_returns_ValidationException() public function test_fill_with_invalid_uri_with_mismatching_issuer_returns_ValidationException()
{ {
$this->expectException(\Illuminate\Validation\ValidationException::class); $this->expectException(\Illuminate\Validation\ValidationException::class);
@ -260,9 +242,7 @@ public function test_fill_with_invalid_uri_with_mismatching_issuer_returns_Valid
$twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI_MISMATCHING_ISSUER); $twofaccount->fillWithURI(OtpTestData::INVALID_OTPAUTH_URI_MISMATCHING_ISSUER);
} }
/** #[Test]
* @test
*/
public function test_fill_with_uri_without_label_returns_ValidationException() public function test_fill_with_uri_without_label_returns_ValidationException()
{ {
$this->expectException(\Illuminate\Validation\ValidationException::class); $this->expectException(\Illuminate\Validation\ValidationException::class);
@ -270,9 +250,7 @@ public function test_fill_with_uri_without_label_returns_ValidationException()
$twofaccount->fillWithURI('otpauth://totp/?secret=' . OtpTestData::SECRET); $twofaccount->fillWithURI('otpauth://totp/?secret=' . OtpTestData::SECRET);
} }
/** #[Test]
* @test
*/
public function test_fill_with_getOfficialIcons_On_triggers_icon_fetching() public function test_fill_with_getOfficialIcons_On_triggers_icon_fetching()
{ {
// Set the getOfficialIcons preference On // Set the getOfficialIcons preference On
@ -291,9 +269,7 @@ public function test_fill_with_getOfficialIcons_On_triggers_icon_fetching()
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP_NO_ICON); $twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP_NO_ICON);
} }
/** #[Test]
* @test
*/
public function test_fill_with_getOfficialIcons_Off_skips_icon_fetching() public function test_fill_with_getOfficialIcons_Off_skips_icon_fetching()
{ {
// Set the getOfficialIcons preference Off // Set the getOfficialIcons preference Off
@ -311,9 +287,7 @@ public function test_fill_with_getOfficialIcons_Off_skips_icon_fetching()
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP); $twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_FULL_VALID_PARAMETERS_FOR_CUSTOM_TOTP);
} }
/** #[Test]
* @test
*/
public function test_create_custom_totp_from_parameters_returns_correct_value() public function test_create_custom_totp_from_parameters_returns_correct_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -330,9 +304,7 @@ public function test_create_custom_totp_from_parameters_returns_correct_value()
$this->assertStringEndsWith('.png', $twofaccount->icon); $this->assertStringEndsWith('.png', $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_create_basic_totp_from_parameters_returns_correct_value() public function test_create_basic_totp_from_parameters_returns_correct_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -349,9 +321,7 @@ public function test_create_basic_totp_from_parameters_returns_correct_value()
$this->assertEquals(null, $twofaccount->icon); $this->assertEquals(null, $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_create_custom_hotp_from_parameters_returns_correct_value() public function test_create_custom_hotp_from_parameters_returns_correct_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -368,9 +338,7 @@ public function test_create_custom_hotp_from_parameters_returns_correct_value()
$this->assertStringEndsWith('.png', $twofaccount->icon); $this->assertStringEndsWith('.png', $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_create_basic_hotp_from_parameters_returns_correct_value() public function test_create_basic_hotp_from_parameters_returns_correct_value()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -387,9 +355,7 @@ public function test_create_basic_hotp_from_parameters_returns_correct_value()
$this->assertEquals(null, $twofaccount->icon); $this->assertEquals(null, $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_create_from_parameters_persists_correct_values_to_db() public function test_create_from_parameters_persists_correct_values_to_db()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -410,9 +376,7 @@ public function test_create_from_parameters_persists_correct_values_to_db()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_create_from_unsupported_parameters_returns_unsupportedOtpTypeException() public function test_create_from_unsupported_parameters_returns_unsupportedOtpTypeException()
{ {
$this->expectException(\App\Exceptions\UnsupportedOtpTypeException::class); $this->expectException(\App\Exceptions\UnsupportedOtpTypeException::class);
@ -420,9 +384,7 @@ public function test_create_from_unsupported_parameters_returns_unsupportedOtpTy
$twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_PARAMETERS_FOR_UNSUPPORTED_OTP_TYPE); $twofaccount->fillWithOtpParameters(OtpTestData::ARRAY_OF_PARAMETERS_FOR_UNSUPPORTED_OTP_TYPE);
} }
/** #[Test]
* @test
*/
public function test_create_from_invalid_parameters_type_returns_InvalidOtpParameterException() public function test_create_from_invalid_parameters_type_returns_InvalidOtpParameterException()
{ {
$this->expectException(\App\Exceptions\InvalidOtpParameterException::class); $this->expectException(\App\Exceptions\InvalidOtpParameterException::class);
@ -434,9 +396,7 @@ public function test_create_from_invalid_parameters_type_returns_InvalidOtpParam
]); ]);
} }
/** #[Test]
* @test
*/
public function test_create_from_invalid_parameters_returns_InvalidOtpParameterException() public function test_create_from_invalid_parameters_returns_InvalidOtpParameterException()
{ {
$this->expectException(\App\Exceptions\InvalidOtpParameterException::class); $this->expectException(\App\Exceptions\InvalidOtpParameterException::class);
@ -448,9 +408,7 @@ public function test_create_from_invalid_parameters_returns_InvalidOtpParameterE
]); ]);
} }
/** #[Test]
* @test
*/
public function test_update_totp_returns_updated_model() public function test_update_totp_returns_updated_model()
{ {
$twofaccount = $this->customTotpTwofaccount; $twofaccount = $this->customTotpTwofaccount;
@ -468,9 +426,7 @@ public function test_update_totp_returns_updated_model()
$this->assertEquals(null, $twofaccount->icon); $this->assertEquals(null, $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_update_hotp_returns_updated_model() public function test_update_hotp_returns_updated_model()
{ {
$twofaccount = $this->customTotpTwofaccount; $twofaccount = $this->customTotpTwofaccount;
@ -488,9 +444,7 @@ public function test_update_hotp_returns_updated_model()
$this->assertEquals(null, $twofaccount->icon); $this->assertEquals(null, $twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_update_totp_persists_updated_model() public function test_update_totp_persists_updated_model()
{ {
$twofaccount = $this->customTotpTwofaccount; $twofaccount = $this->customTotpTwofaccount;
@ -510,9 +464,7 @@ public function test_update_totp_persists_updated_model()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_getOTP_for_totp_returns_the_same_password() public function test_getOTP_for_totp_returns_the_same_password()
{ {
Http::preventStrayRequests(); Http::preventStrayRequests();
@ -540,9 +492,7 @@ public function test_getOTP_for_totp_returns_the_same_password()
} }
} }
/** #[Test]
* @test
*/
public function test_getOTP_for_hotp_returns_the_same_password() public function test_getOTP_for_hotp_returns_the_same_password()
{ {
Http::preventStrayRequests(); Http::preventStrayRequests();
@ -565,9 +515,7 @@ public function test_getOTP_for_hotp_returns_the_same_password()
$this->assertEquals($otp_from_model, $otp_from_parameters); $this->assertEquals($otp_from_model, $otp_from_parameters);
} }
/** #[Test]
* @test
*/
public function test_getOTP_for_steamtotp_returns_the_same_password() public function test_getOTP_for_steamtotp_returns_the_same_password()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -587,9 +535,7 @@ public function test_getOTP_for_steamtotp_returns_the_same_password()
} }
} }
/** #[Test]
* @test
*/
public function test_getOTP_for_totp_with_invalid_secret_returns_InvalidSecretException() public function test_getOTP_for_totp_with_invalid_secret_returns_InvalidSecretException()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -598,9 +544,7 @@ public function test_getOTP_for_totp_with_invalid_secret_returns_InvalidSecretEx
$otp_from_uri = $twofaccount->fillWithURI('otpauth://totp/' . OtpTestData::ACCOUNT . '?secret=1.0')->getOTP(); $otp_from_uri = $twofaccount->fillWithURI('otpauth://totp/' . OtpTestData::ACCOUNT . '?secret=1.0')->getOTP();
} }
/** #[Test]
* @test
*/
public function test_getOTP_for_totp_with_undecipherable_secret_returns_UndecipherableException() public function test_getOTP_for_totp_with_undecipherable_secret_returns_UndecipherableException()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -613,9 +557,7 @@ public function test_getOTP_for_totp_with_undecipherable_secret_returns_Undeciph
])->getOTP(); ])->getOTP();
} }
/** #[Test]
* @test
*/
public function test_getURI_for_custom_totp_model_returns_uri() public function test_getURI_for_custom_totp_model_returns_uri()
{ {
$uri = $this->customTotpTwofaccount->getURI(); $uri = $this->customTotpTwofaccount->getURI();
@ -629,9 +571,7 @@ public function test_getURI_for_custom_totp_model_returns_uri()
$this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri); $this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri);
} }
/** #[Test]
* @test
*/
public function test_getURI_for_custom_hotp_model_returns_uri() public function test_getURI_for_custom_hotp_model_returns_uri()
{ {
$uri = $this->customHotpTwofaccount->getURI(); $uri = $this->customHotpTwofaccount->getURI();
@ -645,9 +585,7 @@ public function test_getURI_for_custom_hotp_model_returns_uri()
$this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri); $this->assertStringContainsString('algorithm=' . OtpTestData::ALGORITHM_CUSTOM, $uri);
} }
/** #[Test]
* @test
*/
public function test_fill_succeed_when_image_fetching_fails() public function test_fill_succeed_when_image_fetching_fails()
{ {
Http::preventStrayRequests(); Http::preventStrayRequests();
@ -662,9 +600,7 @@ public function test_fill_succeed_when_image_fetching_fails()
Storage::disk('imagesLink')->assertDirectoryEmpty('/'); Storage::disk('imagesLink')->assertDirectoryEmpty('/');
} }
/** #[Test]
* @test
*/
public function test_saving_totp_without_period_set_default_one() public function test_saving_totp_without_period_set_default_one()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -680,9 +616,7 @@ public function test_saving_totp_without_period_set_default_one()
$this->assertEquals(TwoFAccount::DEFAULT_PERIOD, $account->period); $this->assertEquals(TwoFAccount::DEFAULT_PERIOD, $account->period);
} }
/** #[Test]
* @test
*/
public function test_saving_hotp_without_counter_set_default_one() public function test_saving_hotp_without_counter_set_default_one()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -698,9 +632,7 @@ public function test_saving_hotp_without_counter_set_default_one()
$this->assertEquals(TwoFAccount::DEFAULT_COUNTER, $account->counter); $this->assertEquals(TwoFAccount::DEFAULT_COUNTER, $account->counter);
} }
/** #[Test]
* @test
*/
public function test_equals_returns_true() public function test_equals_returns_true()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -719,9 +651,7 @@ public function test_equals_returns_true()
$this->assertTrue($twofaccount->equals($this->customTotpTwofaccount)); $this->assertTrue($twofaccount->equals($this->customTotpTwofaccount));
} }
/** #[Test]
* @test
*/
public function test_equals_returns_false() public function test_equals_returns_false()
{ {
$twofaccount = new TwoFAccount; $twofaccount = new TwoFAccount;
@ -740,9 +670,7 @@ public function test_equals_returns_false()
$this->assertFalse($twofaccount->equals($this->customHotpTwofaccount)); $this->assertFalse($twofaccount->equals($this->customHotpTwofaccount));
} }
/** #[Test]
* @test
*/
#[DataProvider('iconResourceProvider')] #[DataProvider('iconResourceProvider')]
public function test_set_icon_stores_and_set_the_icon($res, $ext) public function test_set_icon_stores_and_set_the_icon($res, $ext)
{ {
@ -787,9 +715,7 @@ public static function iconResourceProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidIconResourceProvider')] #[DataProvider('invalidIconResourceProvider')]
public function test_set_invalid_icon_ends_without_error($res, $ext) public function test_set_invalid_icon_ends_without_error($res, $ext)
{ {

View File

@ -13,6 +13,7 @@
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -22,9 +23,7 @@
#[CoversClass(User::class)] #[CoversClass(User::class)]
class UserModelTest extends FeatureTestCase class UserModelTest extends FeatureTestCase
{ {
/** #[Test]
* @test
*/
public function test_admin_scope_returns_only_admin() public function test_admin_scope_returns_only_admin()
{ {
User::factory()->count(4)->create(); User::factory()->count(4)->create();
@ -45,9 +44,7 @@ public function test_admin_scope_returns_only_admin()
$this->assertEquals($admins[1]->name, $secondAdmin->name); $this->assertEquals($admins[1]->name, $secondAdmin->name);
} }
/** #[Test]
* @test
*/
public function test_isAdministrator_returns_correct_state() public function test_isAdministrator_returns_correct_state()
{ {
$user = User::factory()->create(); $user = User::factory()->create();
@ -57,9 +54,7 @@ public function test_isAdministrator_returns_correct_state()
$this->assertEquals($admin->isAdministrator(), true); $this->assertEquals($admin->isAdministrator(), true);
} }
/** #[Test]
* @test
*/
public function test_promoteToAdministrator_sets_administrator_status() public function test_promoteToAdministrator_sets_administrator_status()
{ {
$user = User::factory()->create(); $user = User::factory()->create();
@ -69,9 +64,7 @@ public function test_promoteToAdministrator_sets_administrator_status()
$this->assertEquals($user->isAdministrator(), true); $this->assertEquals($user->isAdministrator(), true);
} }
/** #[Test]
* @test
*/
public function test_promoteToAdministrator_demote_administrator_status() public function test_promoteToAdministrator_demote_administrator_status()
{ {
$admin = User::factory()->administrator()->create(); $admin = User::factory()->administrator()->create();
@ -85,9 +78,7 @@ public function test_promoteToAdministrator_demote_administrator_status()
$this->assertFalse($admin->isAdministrator()); $this->assertFalse($admin->isAdministrator());
} }
/** #[Test]
* @test
*/
public function test_resetPassword_resets_password_with_success() public function test_resetPassword_resets_password_with_success()
{ {
$user = User::factory()->create(); $user = User::factory()->create();
@ -98,9 +89,7 @@ public function test_resetPassword_resets_password_with_success()
$this->assertNotEquals($user->password, $oldPassword); $this->assertNotEquals($user->password, $oldPassword);
} }
/** #[Test]
* @test
*/
public function test_resetPassword_dispatch_event() public function test_resetPassword_dispatch_event()
{ {
Event::fake(); Event::fake();
@ -112,9 +101,7 @@ public function test_resetPassword_dispatch_event()
); );
} }
/** #[Test]
* @test
*/
public function test_delete_removes_user_data() public function test_delete_removes_user_data()
{ {
Artisan::call('passport:install', [ Artisan::call('passport:install', [
@ -171,9 +158,7 @@ public function test_delete_removes_user_data()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_delete_flushes_icons_of_user_twofaccounts() public function test_delete_flushes_icons_of_user_twofaccounts()
{ {
Storage::fake('icons'); Storage::fake('icons');
@ -190,9 +175,7 @@ public function test_delete_flushes_icons_of_user_twofaccounts()
Storage::disk('icons')->assertMissing($twofaccount->icon); Storage::disk('icons')->assertMissing($twofaccount->icon);
} }
/** #[Test]
* @test
*/
public function test_delete_does_not_delete_the_only_admin() public function test_delete_does_not_delete_the_only_admin()
{ {
$admin = User::factory()->administrator()->create(); $admin = User::factory()->administrator()->create();

View File

@ -2,15 +2,12 @@
namespace Tests\Feature; namespace Tests\Feature;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
class RouteTest extends FeatureTestCase class RouteTest extends FeatureTestCase
{ {
/** #[Test]
* test return main web view
*
* @test
*/
public function test_landing_view_is_returned() public function test_landing_view_is_returned()
{ {
$response = $this->get(route('landing', ['any' => '/'])); $response = $this->get(route('landing', ['any' => '/']));
@ -19,11 +16,7 @@ public function test_landing_view_is_returned()
->assertViewIs('landing'); ->assertViewIs('landing');
} }
/** #[Test]
* test return main web view
*
* @test
*/
public function test_exception_handler_with_web_route() public function test_exception_handler_with_web_route()
{ {
$response = $this->post('/'); $response = $this->post('/');

View File

@ -9,6 +9,7 @@
use App\Services\GroupService; use App\Services\GroupService;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -48,9 +49,6 @@ class GroupServiceTest extends FeatureTestCase
private const NEW_GROUP_NAME = 'MyNewGroup'; private const NEW_GROUP_NAME = 'MyNewGroup';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -76,9 +74,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_a_twofaccount_to_a_group_persists_the_relation() public function test_assign_a_twofaccount_to_a_group_persists_the_relation()
{ {
Groups::assign($this->twofaccountOne->id, $this->user, $this->groupTwo); Groups::assign($this->twofaccountOne->id, $this->user, $this->groupTwo);
@ -89,9 +85,7 @@ public function test_assign_a_twofaccount_to_a_group_persists_the_relation()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_multiple_twofaccounts_to_group_persists_the_relation() public function test_assign_multiple_twofaccounts_to_group_persists_the_relation()
{ {
Groups::assign([$this->twofaccountOne->id, $this->twofaccountTwo->id], $this->user, $this->groupTwo); Groups::assign([$this->twofaccountOne->id, $this->twofaccountTwo->id], $this->user, $this->groupTwo);
@ -106,9 +100,7 @@ public function test_assign_multiple_twofaccounts_to_group_persists_the_relation
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_a_twofaccount_to_no_group_assigns_to_user_default_group() public function test_assign_a_twofaccount_to_no_group_assigns_to_user_default_group()
{ {
$this->user['preferences->defaultGroup'] = $this->groupTwo->id; $this->user['preferences->defaultGroup'] = $this->groupTwo->id;
@ -122,9 +114,7 @@ public function test_assign_a_twofaccount_to_no_group_assigns_to_user_default_gr
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_a_twofaccount_to_no_group_assigns_to_user_active_group() public function test_assign_a_twofaccount_to_no_group_assigns_to_user_active_group()
{ {
$this->user['preferences->defaultGroup'] = -1; $this->user['preferences->defaultGroup'] = -1;
@ -139,9 +129,7 @@ public function test_assign_a_twofaccount_to_no_group_assigns_to_user_active_gro
]); ]);
} }
/** #[Test]
* @test
*/
public function test_assign_a_twofaccount_to_missing_active_group_returns_not_found() public function test_assign_a_twofaccount_to_missing_active_group_returns_not_found()
{ {
$orginalGroup = $this->twofaccountOne->group_id; $orginalGroup = $this->twofaccountOne->group_id;
@ -158,9 +146,7 @@ public function test_assign_a_twofaccount_to_missing_active_group_returns_not_fo
]); ]);
} }
/** #[Test]
* @test
*/
public function test_user_can_assign_an_account() public function test_user_can_assign_an_account()
{ {
$this->expectException(AuthorizationException::class); $this->expectException(AuthorizationException::class);
@ -168,9 +154,7 @@ public function test_user_can_assign_an_account()
Groups::assign($this->twofaccountThree->id, $this->user, $this->user->groups()->first()); Groups::assign($this->twofaccountThree->id, $this->user, $this->user->groups()->first());
} }
/** #[Test]
* @test
*/
public function test_user_can_assign_multiple_accounts() public function test_user_can_assign_multiple_accounts()
{ {
$this->expectException(AuthorizationException::class); $this->expectException(AuthorizationException::class);
@ -178,9 +162,7 @@ public function test_user_can_assign_multiple_accounts()
Groups::assign([$this->twofaccountOne->id, $this->twofaccountThree->id], $this->user, $this->user->groups()->first()); Groups::assign([$this->twofaccountOne->id, $this->twofaccountThree->id], $this->user, $this->user->groups()->first());
} }
/** #[Test]
* @test
*/
public function test_prependTheAllGroup_add_the_group_on_top_of_groups() public function test_prependTheAllGroup_add_the_group_on_top_of_groups()
{ {
$groups = Groups::prependTheAllGroup($this->user->groups, $this->user); $groups = Groups::prependTheAllGroup($this->user->groups, $this->user);

View File

@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Data\HttpRequestTestData; use Tests\Data\HttpRequestTestData;
use Tests\TestCase; use Tests\TestCase;
@ -18,17 +19,12 @@ class LogoServiceTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
} }
/** #[Test]
* @test
*/
public function test_getIcon_returns_stored_icon_file_when_logo_exists() public function test_getIcon_returns_stored_icon_file_when_logo_exists()
{ {
$svgLogo = HttpRequestTestData::SVG_LOGO_BODY; $svgLogo = HttpRequestTestData::SVG_LOGO_BODY;
@ -50,9 +46,7 @@ public function test_getIcon_returns_stored_icon_file_when_logo_exists()
Storage::disk('icons')->assertExists($icon); Storage::disk('icons')->assertExists($icon);
} }
/** #[Test]
* @test
*/
public function test_getIcon_returns_null_when_github_request_fails() public function test_getIcon_returns_null_when_github_request_fails()
{ {
Http::preventStrayRequests(); Http::preventStrayRequests();
@ -69,9 +63,7 @@ public function test_getIcon_returns_null_when_github_request_fails()
$this->assertEquals(null, $icon); $this->assertEquals(null, $icon);
} }
/** #[Test]
* @test
*/
public function test_getIcon_returns_null_when_logo_fetching_fails() public function test_getIcon_returns_null_when_logo_fetching_fails()
{ {
$tfaJsonBody = HttpRequestTestData::TFA_JSON_BODY; $tfaJsonBody = HttpRequestTestData::TFA_JSON_BODY;
@ -90,9 +82,7 @@ public function test_getIcon_returns_null_when_logo_fetching_fails()
$this->assertEquals(null, $icon); $this->assertEquals(null, $icon);
} }
/** #[Test]
* @test
*/
public function test_getIcon_returns_null_when_no_logo_exists() public function test_getIcon_returns_null_when_no_logo_exists()
{ {
$logoService = new LogoService(); $logoService = new LogoService();
@ -102,9 +92,7 @@ public function test_getIcon_returns_null_when_no_logo_exists()
$this->assertEquals(null, $icon); $this->assertEquals(null, $icon);
} }
/** #[Test]
* @test
*/
public function test_logoService_loads_empty_collection_when_tfajson_fetching_fails() public function test_logoService_loads_empty_collection_when_tfajson_fetching_fails()
{ {
$svgLogo = HttpRequestTestData::SVG_LOGO_BODY; $svgLogo = HttpRequestTestData::SVG_LOGO_BODY;

View File

@ -5,6 +5,7 @@
use App\Facades\QrCode; use App\Facades\QrCode;
use App\Services\QrCodeService; use App\Services\QrCodeService;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Classes\LocalFile; use Tests\Classes\LocalFile;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -21,25 +22,18 @@ class QrCodeServiceTest extends FeatureTestCase
private const DECODED_IMAGE = 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW'; private const DECODED_IMAGE = 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW';
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
} }
/** #[Test]
* @test
*/
public function test_encode_returns_correct_value() public function test_encode_returns_correct_value()
{ {
$this->assertEquals(self::STRING_ENCODED, QrCode::encode(self::STRING_TO_ENCODE)); $this->assertEquals(self::STRING_ENCODED, QrCode::encode(self::STRING_TO_ENCODE));
} }
/** #[Test]
* @test
*/
public function test_decode_valid_image_returns_correct_value() public function test_decode_valid_image_returns_correct_value()
{ {
$file = LocalFile::fake()->validQrcode(); $file = LocalFile::fake()->validQrcode();
@ -47,9 +41,7 @@ public function test_decode_valid_image_returns_correct_value()
$this->assertEquals(self::DECODED_IMAGE, QrCode::decode($file)); $this->assertEquals(self::DECODED_IMAGE, QrCode::decode($file));
} }
/** #[Test]
* @test
*/
public function test_decode_invalid_image_returns_correct_value() public function test_decode_invalid_image_returns_correct_value()
{ {
$this->expectException(\App\Exceptions\InvalidQrCodeException::class); $this->expectException(\App\Exceptions\InvalidQrCodeException::class);

View File

@ -8,6 +8,7 @@
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Data\HttpRequestTestData; use Tests\Data\HttpRequestTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -19,9 +20,7 @@ class ReleaseRadarServiceTest extends FeatureTestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
public function test_manualScan_returns_no_new_release() public function test_manualScan_returns_no_new_release()
{ {
$url = config('2fauth.latestReleaseUrl'); $url = config('2fauth.latestReleaseUrl');
@ -41,9 +40,7 @@ public function test_manualScan_returns_no_new_release()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_manualScan_returns_new_release() public function test_manualScan_returns_new_release()
{ {
$url = config('2fauth.latestReleaseUrl'); $url = config('2fauth.latestReleaseUrl');
@ -63,9 +60,7 @@ public function test_manualScan_returns_new_release()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_manualScan_complete_when_http_call_fails() public function test_manualScan_complete_when_http_call_fails()
{ {
// We do not fake the http request so an exception will be thrown // We do not fake the http request so an exception will be thrown
@ -74,9 +69,7 @@ public function test_manualScan_complete_when_http_call_fails()
$this->assertNull(ReleaseRadarService::manualScan()); $this->assertNull(ReleaseRadarService::manualScan());
} }
/** #[Test]
* @test
*/
public function test_manualScan_succeed_when_github_is_unreachable() public function test_manualScan_succeed_when_github_is_unreachable()
{ {
$url = config('2fauth.latestReleaseUrl'); $url = config('2fauth.latestReleaseUrl');
@ -89,9 +82,7 @@ public function test_manualScan_succeed_when_github_is_unreachable()
$this->assertNull(ReleaseRadarService::manualScan()); $this->assertNull(ReleaseRadarService::manualScan());
} }
/** #[Test]
* @test
*/
public function test_scheduleScan_runs_after_one_week() public function test_scheduleScan_runs_after_one_week()
{ {
$url = config('2fauth.latestReleaseUrl'); $url = config('2fauth.latestReleaseUrl');
@ -119,9 +110,7 @@ public function test_scheduleScan_runs_after_one_week()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_scheduleScan_does_not_run_before_one_week() public function test_scheduleScan_does_not_run_before_one_week()
{ {
$url = config('2fauth.latestReleaseUrl'); $url = config('2fauth.latestReleaseUrl');
@ -149,9 +138,7 @@ public function test_scheduleScan_does_not_run_before_one_week()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_scheduleScan_complete_when_http_call_fails() public function test_scheduleScan_complete_when_http_call_fails()
{ {
// We do not fake the http request so an exception will be thrown // We do not fake the http request so an exception will be thrown

View File

@ -10,6 +10,7 @@
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
/** /**
@ -62,9 +63,6 @@ class SettingServiceTest extends FeatureTestCase
private const TOTP_FULL_CUSTOM_URI = 'otpauth://totp/' . self::SERVICE . ':' . self::ACCOUNT . '?secret=' . self::SECRET . '&issuer=' . self::SERVICE . '&digits=' . self::DIGITS_CUSTOM . '&period=' . self::PERIOD_CUSTOM . '&algorithm=' . self::ALGORITHM_CUSTOM . '&image=' . self::IMAGE; private const TOTP_FULL_CUSTOM_URI = 'otpauth://totp/' . self::SERVICE . ':' . self::ACCOUNT . '?secret=' . self::SECRET . '&issuer=' . self::SERVICE . '&digits=' . self::DIGITS_CUSTOM . '&period=' . self::PERIOD_CUSTOM . '&algorithm=' . self::ALGORITHM_CUSTOM . '&image=' . self::IMAGE;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -96,9 +94,7 @@ public function setUp() : void
$this->twofaccountTwo->save(); $this->twofaccountTwo->save();
} }
/** #[Test]
* @test
*/
public function test_get_string_setting_returns_correct_value() public function test_get_string_setting_returns_correct_value()
{ {
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_STRING); Settings::set(self::SETTING_NAME, self::SETTING_VALUE_STRING);
@ -106,9 +102,7 @@ public function test_get_string_setting_returns_correct_value()
$this->assertEquals(self::SETTING_VALUE_STRING, Settings::get(self::SETTING_NAME)); $this->assertEquals(self::SETTING_VALUE_STRING, Settings::get(self::SETTING_NAME));
} }
/** #[Test]
* @test
*/
public function test_get_boolean_setting_returns_true() public function test_get_boolean_setting_returns_true()
{ {
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_TRUE_TRANSFORMED); Settings::set(self::SETTING_NAME, self::SETTING_VALUE_TRUE_TRANSFORMED);
@ -116,9 +110,7 @@ public function test_get_boolean_setting_returns_true()
$this->assertEquals(true, Settings::get(self::SETTING_NAME)); $this->assertEquals(true, Settings::get(self::SETTING_NAME));
} }
/** #[Test]
* @test
*/
public function test_get_boolean_setting_returns_false() public function test_get_boolean_setting_returns_false()
{ {
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FALSE_TRANSFORMED); Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FALSE_TRANSFORMED);
@ -126,9 +118,7 @@ public function test_get_boolean_setting_returns_false()
$this->assertEquals(false, Settings::get(self::SETTING_NAME)); $this->assertEquals(false, Settings::get(self::SETTING_NAME));
} }
/** #[Test]
* @test
*/
public function test_get_int_setting_returns_int() public function test_get_int_setting_returns_int()
{ {
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_INT); Settings::set(self::SETTING_NAME, self::SETTING_VALUE_INT);
@ -139,9 +129,7 @@ public function test_get_int_setting_returns_int()
$this->assertIsInt($value); $this->assertIsInt($value);
} }
/** #[Test]
* @test
*/
public function test_get_float_setting_returns_float() public function test_get_float_setting_returns_float()
{ {
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FLOAT); Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FLOAT);
@ -152,9 +140,7 @@ public function test_get_float_setting_returns_float()
$this->assertIsFloat($value); $this->assertIsFloat($value);
} }
/** #[Test]
* @test
*/
public function test_all_returns_default_and_overloaded_settings() public function test_all_returns_default_and_overloaded_settings()
{ {
$default_options = config('2fauth.settings'); $default_options = config('2fauth.settings');
@ -172,9 +158,7 @@ public function test_all_returns_default_and_overloaded_settings()
} }
} }
/** #[Test]
* @test
*/
public function test_set_setting_persist_correct_value_in_db_and_cache() public function test_set_setting_persist_correct_value_in_db_and_cache()
{ {
$value = Settings::set(self::SETTING_NAME, self::SETTING_VALUE_STRING); $value = Settings::set(self::SETTING_NAME, self::SETTING_VALUE_STRING);
@ -188,9 +172,7 @@ public function test_set_setting_persist_correct_value_in_db_and_cache()
$this->assertEquals($cached->get(self::SETTING_NAME), self::SETTING_VALUE_STRING); $this->assertEquals($cached->get(self::SETTING_NAME), self::SETTING_VALUE_STRING);
} }
/** #[Test]
* @test
*/
public function test_set_useEncryption_on_encrypts_all_accounts() public function test_set_useEncryption_on_encrypts_all_accounts()
{ {
Settings::set('useEncryption', true); Settings::set('useEncryption', true);
@ -204,9 +186,7 @@ public function test_set_useEncryption_on_encrypts_all_accounts()
}); });
} }
/** #[Test]
* @test
*/
public function test_set_useEncryption_on_twice_prevents_successive_encryption() public function test_set_useEncryption_on_twice_prevents_successive_encryption()
{ {
Settings::set('useEncryption', true); Settings::set('useEncryption', true);
@ -221,9 +201,7 @@ public function test_set_useEncryption_on_twice_prevents_successive_encryption()
}); });
} }
/** #[Test]
* @test
*/
public function test_set_useEncryption_off_decrypts_all_accounts() public function test_set_useEncryption_off_decrypts_all_accounts()
{ {
Settings::set('useEncryption', true); Settings::set('useEncryption', true);
@ -238,9 +216,7 @@ public function test_set_useEncryption_off_decrypts_all_accounts()
}); });
} }
/** #[Test]
* @test
*/
#[DataProvider('provideUndecipherableData')] #[DataProvider('provideUndecipherableData')]
public function test_set_useEncryption_off_returns_exception_when_data_are_undecipherable(array $data) public function test_set_useEncryption_off_returns_exception_when_data_are_undecipherable(array $data)
{ {
@ -275,9 +251,7 @@ public static function provideUndecipherableData() : array
]; ];
} }
/** #[Test]
* @test
*/
public function test_set_array_of_settings_persist_correct_values() public function test_set_array_of_settings_persist_correct_values()
{ {
$value = Settings::set([ $value = Settings::set([
@ -300,9 +274,7 @@ public function test_set_array_of_settings_persist_correct_values()
$this->assertEquals($cached->get(self::SETTING_NAME_ALT), self::SETTING_VALUE_INT); $this->assertEquals($cached->get(self::SETTING_NAME_ALT), self::SETTING_VALUE_INT);
} }
/** #[Test]
* @test
*/
public function test_set_true_setting_persist_transformed_boolean() public function test_set_true_setting_persist_transformed_boolean()
{ {
$value = Settings::set(self::SETTING_NAME, true); $value = Settings::set(self::SETTING_NAME, true);
@ -313,9 +285,7 @@ public function test_set_true_setting_persist_transformed_boolean()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_set_false_setting_persist_transformed_boolean() public function test_set_false_setting_persist_transformed_boolean()
{ {
$value = Settings::set(self::SETTING_NAME, false); $value = Settings::set(self::SETTING_NAME, false);
@ -326,9 +296,7 @@ public function test_set_false_setting_persist_transformed_boolean()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_del_remove_setting_from_db_and_cache() public function test_del_remove_setting_from_db_and_cache()
{ {
DB::table('options')->insert( DB::table('options')->insert(
@ -345,9 +313,7 @@ public function test_del_remove_setting_from_db_and_cache()
$this->assertFalse($cached->has(self::SETTING_NAME)); $this->assertFalse($cached->has(self::SETTING_NAME));
} }
/** #[Test]
* @test
*/
public function test_isEdited_returns_true() public function test_isEdited_returns_true()
{ {
DB::table('options')->insert( DB::table('options')->insert(
@ -357,9 +323,7 @@ public function test_isEdited_returns_true()
$this->assertTrue(Settings::isEdited('showOtpAsDot')); $this->assertTrue(Settings::isEdited('showOtpAsDot'));
} }
/** #[Test]
* @test
*/
public function test_isEdited_returns_false() public function test_isEdited_returns_false()
{ {
DB::table('options')->where(self::KEY, 'showOtpAsDot')->delete(); DB::table('options')->where(self::KEY, 'showOtpAsDot')->delete();
@ -367,9 +331,7 @@ public function test_isEdited_returns_false()
$this->assertFalse(Settings::isEdited('showOtpAsDot')); $this->assertFalse(Settings::isEdited('showOtpAsDot'));
} }
/** #[Test]
* @test
*/
public function test_cache_is_requested_at_instanciation() public function test_cache_is_requested_at_instanciation()
{ {
Cache::shouldReceive('remember') Cache::shouldReceive('remember')
@ -380,9 +342,7 @@ public function test_cache_is_requested_at_instanciation()
Cache::shouldHaveReceived('remember'); Cache::shouldHaveReceived('remember');
} }
/** #[Test]
* @test
*/
public function test_cache_is_updated_when_setting_is_set() public function test_cache_is_updated_when_setting_is_set()
{ {
Cache::shouldReceive('remember', 'put') Cache::shouldReceive('remember', 'put')
@ -394,9 +354,7 @@ public function test_cache_is_updated_when_setting_is_set()
Cache::shouldHaveReceived('put'); Cache::shouldHaveReceived('put');
} }
/** #[Test]
* @test
*/
public function test_cache_is_updated_when_setting_is_deleted() public function test_cache_is_updated_when_setting_is_deleted()
{ {
Cache::shouldReceive('remember', 'put') Cache::shouldReceive('remember', 'put')

View File

@ -8,6 +8,7 @@
use App\Models\User; use App\Models\User;
use App\Services\TwoFAccountService; use App\Services\TwoFAccountService;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Data\MigrationTestData; use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\FeatureTestCase; use Tests\FeatureTestCase;
@ -38,9 +39,6 @@ class TwoFAccountServiceTest extends FeatureTestCase
protected $userGroupB; protected $userGroupB;
/**
* @test
*/
public function setUp() : void public function setUp() : void
{ {
parent::setUp(); parent::setUp();
@ -76,9 +74,7 @@ public function setUp() : void
]); ]);
} }
/** #[Test]
* @test
*/
public function test_withdraw_comma_separated_ids_deletes_relation() public function test_withdraw_comma_separated_ids_deletes_relation()
{ {
$twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]); $twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]);
@ -107,9 +103,7 @@ public function test_withdraw_comma_separated_ids_deletes_relation()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_withdraw_array_of_ids_deletes_relation() public function test_withdraw_array_of_ids_deletes_relation()
{ {
$twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]); $twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]);
@ -137,9 +131,7 @@ public function test_withdraw_array_of_ids_deletes_relation()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_withdraw_single_id_deletes_relation() public function test_withdraw_single_id_deletes_relation()
{ {
$twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]); $twofaccounts = collect([$this->customHotpTwofaccount, $this->customTotpTwofaccount]);
@ -158,17 +150,13 @@ public function test_withdraw_single_id_deletes_relation()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_withdraw_missing_ids_returns_void() public function test_withdraw_missing_ids_returns_void()
{ {
$this->assertNull(TwoFAccounts::withdraw(null)); $this->assertNull(TwoFAccounts::withdraw(null));
} }
/** #[Test]
* @test
*/
public function test_migrate_from_gauth_returns_correct_accounts() public function test_migrate_from_gauth_returns_correct_accounts()
{ {
$this->actingAs($this->user); $this->actingAs($this->user);
@ -196,9 +184,7 @@ public function test_migrate_from_gauth_returns_correct_accounts()
$this->assertEquals(OtpTestData::ALGORITHM_DEFAULT, $twofaccounts->last()->algorithm); $this->assertEquals(OtpTestData::ALGORITHM_DEFAULT, $twofaccounts->last()->algorithm);
} }
/** #[Test]
* @test
*/
public function test_migrate_from_gauth_returns_flagged_duplicates() public function test_migrate_from_gauth_returns_flagged_duplicates()
{ {
$this->actingAs($this->user, 'api-guard'); $this->actingAs($this->user, 'api-guard');
@ -227,18 +213,14 @@ public function test_migrate_from_gauth_returns_flagged_duplicates()
$this->assertEquals(-1, $twofaccounts->last()->id); $this->assertEquals(-1, $twofaccounts->last()->id);
} }
/** #[Test]
* @test
*/
public function test_migrate_invalid_migration_from_gauth_returns_InvalidMigrationData_exception() public function test_migrate_invalid_migration_from_gauth_returns_InvalidMigrationData_exception()
{ {
$this->expectException(\App\Exceptions\InvalidMigrationDataException::class); $this->expectException(\App\Exceptions\InvalidMigrationDataException::class);
$twofaccounts = TwoFAccounts::migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA); $twofaccounts = TwoFAccounts::migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA);
} }
/** #[Test]
* @test
*/
public function test_export_single_id_returns_collection() public function test_export_single_id_returns_collection()
{ {
$twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id); $twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id);
@ -247,9 +229,7 @@ public function test_export_single_id_returns_collection()
$this->assertObjectEquals($this->customTotpTwofaccount, $twofaccounts->first()); $this->assertObjectEquals($this->customTotpTwofaccount, $twofaccounts->first());
} }
/** #[Test]
* @test
*/
public function test_export_comma_separated_ids_returns_collection() public function test_export_comma_separated_ids_returns_collection()
{ {
$twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id . ',' . $this->customHotpTwofaccount->id); $twofaccounts = TwoFAccounts::export($this->customTotpTwofaccount->id . ',' . $this->customHotpTwofaccount->id);
@ -259,9 +239,7 @@ public function test_export_comma_separated_ids_returns_collection()
$this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last()); $this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last());
} }
/** #[Test]
* @test
*/
public function test_export_array_of_ids_returns_collection() public function test_export_array_of_ids_returns_collection()
{ {
$twofaccounts = TwoFAccounts::export([$this->customTotpTwofaccount->id, $this->customHotpTwofaccount->id]); $twofaccounts = TwoFAccounts::export([$this->customTotpTwofaccount->id, $this->customHotpTwofaccount->id]);
@ -271,9 +249,7 @@ public function test_export_array_of_ids_returns_collection()
$this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last()); $this->assertObjectEquals($this->customHotpTwofaccount, $twofaccounts->last());
} }
/** #[Test]
* @test
*/
public function test_delete_comma_separated_ids() public function test_delete_comma_separated_ids()
{ {
$twofaccounts = TwoFAccount::factory()->count(2)->for($this->user)->create(); $twofaccounts = TwoFAccount::factory()->count(2)->for($this->user)->create();
@ -295,9 +271,7 @@ public function test_delete_comma_separated_ids()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_delete_array_of_ids() public function test_delete_array_of_ids()
{ {
$twofaccounts = TwoFAccount::factory()->count(2)->for($this->user)->create(); $twofaccounts = TwoFAccount::factory()->count(2)->for($this->user)->create();
@ -319,9 +293,7 @@ public function test_delete_array_of_ids()
]); ]);
} }
/** #[Test]
* @test
*/
public function test_delete_single_id() public function test_delete_single_id()
{ {
$twofaccount = TwoFAccount::factory()->for($this->user)->create(); $twofaccount = TwoFAccount::factory()->for($this->user)->create();

View File

@ -14,6 +14,7 @@
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Mockery; use Mockery;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -41,9 +42,7 @@ public function setUp() : void
$this->app['auth']->shouldUse(null); $this->app['auth']->shouldUse(null);
} }
/** #[Test]
* @test
*/
public function test_index_returns_api_resources() public function test_index_returns_api_resources()
{ {
$user = Mockery::mock(User::class); $user = Mockery::mock(User::class);
@ -67,9 +66,7 @@ public function test_index_returns_api_resources()
$this->assertContainsOnlyInstancesOf(GroupResource::class, $response->collection); $this->assertContainsOnlyInstancesOf(GroupResource::class, $response->collection);
} }
/** #[Test]
* @test
*/
public function test_store_uses_validated_data_and_returns_api_resource() public function test_store_uses_validated_data_and_returns_api_resource()
{ {
$request = Mockery::mock(GroupStoreRequest::class); $request = Mockery::mock(GroupStoreRequest::class);
@ -88,9 +85,7 @@ public function test_store_uses_validated_data_and_returns_api_resource()
// $this->assertInstanceOf(GroupResource::class, $response); // $this->assertInstanceOf(GroupResource::class, $response);
} }
/** #[Test]
* @test
*/
public function test_show_returns_api_resource() public function test_show_returns_api_resource()
{ {
$controller = Mockery::mock(GroupController::class)->makePartial(); $controller = Mockery::mock(GroupController::class)->makePartial();
@ -101,9 +96,7 @@ public function test_show_returns_api_resource()
$this->assertInstanceOf(GroupResource::class, $response); $this->assertInstanceOf(GroupResource::class, $response);
} }
/** #[Test]
* @test
*/
public function test_update_validates_data_and_returns_api_resource() public function test_update_validates_data_and_returns_api_resource()
{ {
$request = Mockery::mock(GroupStoreRequest::class); $request = Mockery::mock(GroupStoreRequest::class);
@ -120,9 +113,7 @@ public function test_update_validates_data_and_returns_api_resource()
$this->assertInstanceOf(GroupResource::class, $response); $this->assertInstanceOf(GroupResource::class, $response);
} }
/** #[Test]
* @test
*/
public function test_assignAccounts_returns_api_resource_assigned_using_groupService() public function test_assignAccounts_returns_api_resource_assigned_using_groupService()
{ {
$request = Mockery::mock(GroupAssignRequest::class); $request = Mockery::mock(GroupAssignRequest::class);
@ -144,9 +135,7 @@ public function test_assignAccounts_returns_api_resource_assigned_using_groupSer
$this->assertInstanceOf(GroupResource::class, $response); $this->assertInstanceOf(GroupResource::class, $response);
} }
/** #[Test]
* @test
*/
public function test_accounts_returns_api_resources() public function test_accounts_returns_api_resources()
{ {
$controller = Mockery::mock(GroupController::class)->makePartial(); $controller = Mockery::mock(GroupController::class)->makePartial();
@ -157,9 +146,7 @@ public function test_accounts_returns_api_resources()
$this->assertContainsOnlyInstancesOf(TwoFAccountReadResource::class, $response->collection); $this->assertContainsOnlyInstancesOf(TwoFAccountReadResource::class, $response->collection);
} }
/** #[Test]
* @test
*/
public function test_destroy_uses_group_service() public function test_destroy_uses_group_service()
{ {
$controller = Mockery::mock(GroupController::class)->makePartial(); $controller = Mockery::mock(GroupController::class)->makePartial();

View File

@ -5,6 +5,7 @@
use App\Events\GroupDeleted; use App\Events\GroupDeleted;
use App\Models\Group; use App\Models\Group;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -13,9 +14,7 @@
#[CoversClass(GroupDeleted::class)] #[CoversClass(GroupDeleted::class)]
class GroupDeletedTest extends TestCase class GroupDeletedTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_event_constructor() public function test_event_constructor()
{ {
$group = Group::factory()->make(); $group = Group::factory()->make();

View File

@ -5,6 +5,7 @@
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use App\Models\Group; use App\Models\Group;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -13,9 +14,7 @@
#[CoversClass(GroupDeleting::class)] #[CoversClass(GroupDeleting::class)]
class GroupDeletingTest extends TestCase class GroupDeletingTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_event_constructor() public function test_event_constructor()
{ {
$group = Group::factory()->make(); $group = Group::factory()->make();

View File

@ -7,6 +7,7 @@
use App\Services\SettingService; use App\Services\SettingService;
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -15,9 +16,7 @@
#[CoversClass(TwoFAccountDeleted::class)] #[CoversClass(TwoFAccountDeleted::class)]
class TwoFAccountDeletedTest extends TestCase class TwoFAccountDeletedTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_event_constructor() public function test_event_constructor()
{ {
$settingService = $this->mock(SettingService::class, function (MockInterface $settingService) { $settingService = $this->mock(SettingService::class, function (MockInterface $settingService) {

View File

@ -17,6 +17,7 @@
use Illuminate\Http\Request; use Illuminate\Http\Request;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -25,9 +26,7 @@
#[CoversClass(Handler::class)] #[CoversClass(Handler::class)]
class HandlerTest extends TestCase class HandlerTest extends TestCase
{ {
/** #[Test]
* @test
*/
#[DataProvider('provideExceptionsforBadRequest')] #[DataProvider('provideExceptionsforBadRequest')]
public function test_exceptions_returns_badRequest_json_response($exception) public function test_exceptions_returns_badRequest_json_response($exception)
{ {
@ -85,9 +84,7 @@ public static function provideExceptionsforBadRequest() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideExceptionsforNotFound')] #[DataProvider('provideExceptionsforNotFound')]
public function test_exceptions_returns_notFound_json_response($exception) public function test_exceptions_returns_notFound_json_response($exception)
{ {
@ -124,9 +121,7 @@ public static function provideExceptionsforNotFound() : array
]; ];
} }
/** #[Test]
* @test
*/
public function test_authenticationException_returns_unauthorized_json_response() public function test_authenticationException_returns_unauthorized_json_response()
{ {
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
@ -150,9 +145,7 @@ public function test_authenticationException_returns_unauthorized_json_response(
]); ]);
} }
/** #[Test]
* @test
*/
public function test_authenticationException_returns_proxyAuthRequired_json_response_with_proxy_guard() public function test_authenticationException_returns_proxyAuthRequired_json_response_with_proxy_guard()
{ {
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
@ -176,9 +169,7 @@ public function test_authenticationException_returns_proxyAuthRequired_json_resp
]); ]);
} }
/** #[Test]
* @test
*/
public function test_AccessDeniedException_returns_forbidden_json_response() public function test_AccessDeniedException_returns_forbidden_json_response()
{ {
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);

View File

@ -8,6 +8,7 @@
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\ModelTestCase; use Tests\ModelTestCase;
/** /**
@ -16,9 +17,7 @@
#[CoversClass(Group::class)] #[CoversClass(Group::class)]
class GroupModelTest extends ModelTestCase class GroupModelTest extends ModelTestCase
{ {
/** #[Test]
* @test
*/
public function test_model_configuration() public function test_model_configuration()
{ {
$this->runConfigurationAssertions( $this->runConfigurationAssertions(
@ -39,9 +38,7 @@ public function test_model_configuration()
); );
} }
/** #[Test]
* @test
*/
public function test_twofaccounts_relation() public function test_twofaccounts_relation()
{ {
$group = new Group(); $group = new Group();
@ -49,9 +46,7 @@ public function test_twofaccounts_relation()
$this->assertHasManyRelation($accounts, $group, new TwoFAccount()); $this->assertHasManyRelation($accounts, $group, new TwoFAccount());
} }
/** #[Test]
* @test
*/
public function test_user_relation() public function test_user_relation()
{ {
$model = new Group; $model = new Group;

View File

@ -5,6 +5,7 @@
use App\Helpers\Helpers; use App\Helpers\Helpers;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -13,9 +14,7 @@
#[CoversClass(Helpers::class)] #[CoversClass(Helpers::class)]
class HelpersTest extends TestCase class HelpersTest extends TestCase
{ {
/** #[Test]
* @test
*/
#[DataProvider('versionNumberProvider')] #[DataProvider('versionNumberProvider')]
public function test_cleanVersionNumber_returns_cleaned_version($dirtyVersion, $expected) public function test_cleanVersionNumber_returns_cleaned_version($dirtyVersion, $expected)
{ {
@ -49,9 +48,7 @@ public static function versionNumberProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidVersionNumberProvider')] #[DataProvider('invalidVersionNumberProvider')]
public function test_cleanVersionNumber_returns_false_with_invalid_semver($dirtyVersion) public function test_cleanVersionNumber_returns_false_with_invalid_semver($dirtyVersion)
{ {
@ -84,9 +81,7 @@ public static function invalidVersionNumberProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('toBase32PaddedStringProvider')] #[DataProvider('toBase32PaddedStringProvider')]
public function test_toBase32Format_returns_base32_formated_string($str, $expected) public function test_toBase32Format_returns_base32_formated_string($str, $expected)
{ {
@ -136,9 +131,7 @@ public static function toBase32PaddedStringProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('commaSeparatedToArrayProvider')] #[DataProvider('commaSeparatedToArrayProvider')]
public function test_commaSeparatedToArray_returns_ids_in_array($str, $expected) public function test_commaSeparatedToArray_returns_ids_in_array($str, $expected)
{ {
@ -164,9 +157,7 @@ public static function commaSeparatedToArrayProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidCommaSeparatedToArrayProvider')] #[DataProvider('invalidCommaSeparatedToArrayProvider')]
public function test_commaSeparatedToArray_returns_unchanged_ids($str, $expected) public function test_commaSeparatedToArray_returns_unchanged_ids($str, $expected)
{ {

View File

@ -6,6 +6,7 @@
use Illuminate\Auth\Events\Failed; use Illuminate\Auth\Events\Failed;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(FailedLoginListener::class)] #[CoversClass(FailedLoginListener::class)]
class FailedLoginListenerTest extends TestCase class FailedLoginListenerTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_FailedLoginListener_listen_to_Failed_event() public function test_FailedLoginListener_listen_to_Failed_event()
{ {
Event::fake(); Event::fake();

View File

@ -6,6 +6,7 @@
use Illuminate\Auth\Events\Login; use Illuminate\Auth\Events\Login;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(LoginListener::class)] #[CoversClass(LoginListener::class)]
class LoginListenerTest extends TestCase class LoginListenerTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_LoginListener_listen_to_Login_event() public function test_LoginListener_listen_to_Login_event()
{ {
Event::fake(); Event::fake();

View File

@ -6,6 +6,7 @@
use Illuminate\Auth\Events\Logout; use Illuminate\Auth\Events\Logout;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(LogoutListener::class)] #[CoversClass(LogoutListener::class)]
class LogoutListenerTest extends TestCase class LogoutListenerTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_LogoutListener_listen_to_Logout_event() public function test_LogoutListener_listen_to_Logout_event()
{ {
Event::fake(); Event::fake();

View File

@ -6,6 +6,7 @@
use App\Listeners\Authentication\VisitedByProxyUserListener; use App\Listeners\Authentication\VisitedByProxyUserListener;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(VisitedByProxyUserListener::class)] #[CoversClass(VisitedByProxyUserListener::class)]
class VisitedByProxyUserListenerTest extends TestCase class VisitedByProxyUserListenerTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_VisitedByProxyUserListener_listen_to_VisitedByProxyUser_event() public function test_VisitedByProxyUserListener_listen_to_VisitedByProxyUser_event()
{ {
Event::fake(); Event::fake();

View File

@ -10,6 +10,7 @@
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -18,9 +19,7 @@
#[CoversClass(CleanIconStorage::class)] #[CoversClass(CleanIconStorage::class)]
class CleanIconStorageTest extends TestCase class CleanIconStorageTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_it_deletes_icon_file_using_storage_facade() public function test_it_deletes_icon_file_using_storage_facade()
{ {
$settingService = $this->mock(SettingService::class, function (MockInterface $settingService) { $settingService = $this->mock(SettingService::class, function (MockInterface $settingService) {
@ -39,9 +38,7 @@ public function test_it_deletes_icon_file_using_storage_facade()
$this->assertNull($listener->handle($event)); $this->assertNull($listener->handle($event));
} }
/** #[Test]
* @test
*/
public function test_CleanIconStorage_listen_to_TwoFAccountDeleted_event() public function test_CleanIconStorage_listen_to_TwoFAccountDeleted_event()
{ {
Event::fake(); Event::fake();

View File

@ -6,6 +6,7 @@
use App\Listeners\DissociateTwofaccountFromGroup; use App\Listeners\DissociateTwofaccountFromGroup;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(DissociateTwofaccountFromGroup::class)] #[CoversClass(DissociateTwofaccountFromGroup::class)]
class DissociateTwofaccountFromGroupTest extends TestCase class DissociateTwofaccountFromGroupTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_DissociateTwofaccountFromGroup_listen_to_groupDeleting_event() public function test_DissociateTwofaccountFromGroup_listen_to_groupDeleting_event()
{ {
Event::fake(); Event::fake();

View File

@ -6,6 +6,7 @@
use Illuminate\Notifications\Events\NotificationSent; use Illuminate\Notifications\Events\NotificationSent;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(LogNotification::class)] #[CoversClass(LogNotification::class)]
class LogNotificationTest extends TestCase class LogNotificationTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_LogNotificationTest_listen_to_NotificationSent_event() public function test_LogNotificationTest_listen_to_NotificationSent_event()
{ {
Event::fake(); Event::fake();

View File

@ -8,6 +8,7 @@
use Laravel\Socialite\Contracts\Factory as SocialiteFactory; use Laravel\Socialite\Contracts\Factory as SocialiteFactory;
use Laravel\Socialite\SocialiteManager; use Laravel\Socialite\SocialiteManager;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use SocialiteProviders\Manager\SocialiteWasCalled; use SocialiteProviders\Manager\SocialiteWasCalled;
use Tests\TestCase; use Tests\TestCase;
@ -17,9 +18,7 @@
#[CoversClass(RegisterOpenId::class)] #[CoversClass(RegisterOpenId::class)]
class RegisterOpenIdTest extends TestCase class RegisterOpenIdTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_it_registers_openId_driver() public function test_it_registers_openId_driver()
{ {
/** @var SocialiteManager $socialite */ /** @var SocialiteManager $socialite */
@ -30,9 +29,7 @@ public function test_it_registers_openId_driver()
$this->assertInstanceOf(OpenId::class, $driver); $this->assertInstanceOf(OpenId::class, $driver);
} }
/** #[Test]
* @test
*/
public function test_RegisterOpenId_listen_to_SocialiteWasCalled_event() public function test_RegisterOpenId_listen_to_SocialiteWasCalled_event()
{ {
Event::fake(); Event::fake();

View File

@ -8,6 +8,7 @@
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -16,9 +17,7 @@
#[CoversClass(ReleaseRadar::class)] #[CoversClass(ReleaseRadar::class)]
class ReleaseRadarTest extends TestCase class ReleaseRadarTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_it_starts_release_scan() public function test_it_starts_release_scan()
{ {
$this->mock(ReleaseRadarService::class, function (MockInterface $releaseRadarService) { $this->mock(ReleaseRadarService::class, function (MockInterface $releaseRadarService) {
@ -31,9 +30,7 @@ public function test_it_starts_release_scan()
$this->assertNull($listener->handle($event)); $this->assertNull($listener->handle($event));
} }
/** #[Test]
* @test
*/
public function test_ReleaseRadar_listen_to_ScanForNewReleaseCalled_event() public function test_ReleaseRadar_listen_to_ScanForNewReleaseCalled_event()
{ {
Event::fake(); Event::fake();

View File

@ -6,6 +6,7 @@
use App\Listeners\ResetUsersPreference; use App\Listeners\ResetUsersPreference;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(ResetUsersPreference::class)] #[CoversClass(ResetUsersPreference::class)]
class ResetUsersPreferenceTest extends TestCase class ResetUsersPreferenceTest extends TestCase
{ {
/** #[Test]
* @test
*/
public function test_ResetUsersPreference_listen_to_GroupDeleted_event() public function test_ResetUsersPreference_listen_to_GroupDeleted_event()
{ {
Event::fake(); Event::fake();

View File

@ -20,6 +20,7 @@
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\Data\MigrationTestData; use Tests\Data\MigrationTestData;
use Tests\Data\OtpTestData; use Tests\Data\OtpTestData;
use Tests\TestCase; use Tests\TestCase;
@ -150,9 +151,7 @@ protected function tearDown() : void
parent::tearDown(); parent::tearDown();
} }
/** #[Test]
* @test
*/
#[DataProvider('validMigrationsProvider')] #[DataProvider('validMigrationsProvider')]
public function test_migrate_returns_consistent_accounts(Migrator $migrator, mixed $payload, string $expected, bool $hasSteam) public function test_migrate_returns_consistent_accounts(Migrator $migrator, mixed $payload, string $expected, bool $hasSteam)
{ {
@ -226,9 +225,7 @@ public static function validMigrationsProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('invalidMigrationsProvider')] #[DataProvider('invalidMigrationsProvider')]
public function test_migrate_with_invalid_payload_returns_InvalidMigrationDataException(Migrator $migrator, mixed $payload) public function test_migrate_with_invalid_payload_returns_InvalidMigrationDataException(Migrator $migrator, mixed $payload)
{ {
@ -295,9 +292,7 @@ public static function invalidMigrationsProvider()
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('migrationWithInvalidAccountsProvider')] #[DataProvider('migrationWithInvalidAccountsProvider')]
public function test_migrate_returns_fake_accounts(Migrator $migrator, mixed $payload) public function test_migrate_returns_fake_accounts(Migrator $migrator, mixed $payload)
{ {
@ -337,9 +332,7 @@ public static function migrationWithInvalidAccountsProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_migrate_gauth_returns_fake_accounts() public function test_migrate_gauth_returns_fake_accounts()
{ {
$migrator = $this->partialMock(GoogleAuthMigrator::class, function (MockInterface $migrator) { $migrator = $this->partialMock(GoogleAuthMigrator::class, function (MockInterface $migrator) {
@ -361,9 +354,7 @@ public function test_migrate_gauth_returns_fake_accounts()
$this->forgetMock(GoogleAuthMigrator::class); $this->forgetMock(GoogleAuthMigrator::class);
} }
/** #[Test]
* @test
*/
#[DataProvider('AegisWithIconMigrationProvider')] #[DataProvider('AegisWithIconMigrationProvider')]
public function test_migrate_aegis_payload_with_icon_sets_and_stores_the_icon($migration) public function test_migrate_aegis_payload_with_icon_sets_and_stores_the_icon($migration)
{ {
@ -396,9 +387,7 @@ public static function AegisWithIconMigrationProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_migrate_aegis_payload_with_unsupported_icon_does_not_fail() public function test_migrate_aegis_payload_with_unsupported_icon_does_not_fail()
{ {
Storage::fake('icons'); Storage::fake('icons');
@ -413,9 +402,7 @@ public function test_migrate_aegis_payload_with_unsupported_icon_does_not_fail()
Storage::disk('icons')->assertDirectoryEmpty('/'); Storage::disk('icons')->assertDirectoryEmpty('/');
} }
/** #[Test]
* @test
*/
#[DataProvider('TwoFAuthWithIconMigrationProvider')] #[DataProvider('TwoFAuthWithIconMigrationProvider')]
public function test_migrate_2fauth_payload_with_icon_sets_and_stores_the_icon($migration) public function test_migrate_2fauth_payload_with_icon_sets_and_stores_the_icon($migration)
{ {
@ -454,9 +441,7 @@ public static function TwoFAuthWithIconMigrationProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_migrate_2fauth_payload_with_unsupported_icon_does_not_fail() public function test_migrate_2fauth_payload_with_unsupported_icon_does_not_fail()
{ {
Storage::fake('icons'); Storage::fake('icons');
@ -471,9 +456,7 @@ public function test_migrate_2fauth_payload_with_unsupported_icon_does_not_fail(
Storage::disk('icons')->assertDirectoryEmpty('/'); Storage::disk('icons')->assertDirectoryEmpty('/');
} }
/** #[Test]
* @test
*/
#[DataProvider('factoryProvider')] #[DataProvider('factoryProvider')]
public function test_factory_returns_relevant_migrator($payload, $migratorClass) public function test_factory_returns_relevant_migrator($payload, $migratorClass)
{ {
@ -517,9 +500,7 @@ public static function factoryProvider()
]; ];
} }
/** #[Test]
* @test
*/
public function test_factory_throw_UnsupportedMigrationException() public function test_factory_throw_UnsupportedMigrationException()
{ {
$this->expectException(UnsupportedMigrationException::class); $this->expectException(UnsupportedMigrationException::class);
@ -528,9 +509,7 @@ public function test_factory_throw_UnsupportedMigrationException()
$migrator = $factory->create('not_a_valid_payload'); $migrator = $factory->create('not_a_valid_payload');
} }
/** #[Test]
* @test
*/
#[DataProvider('encryptedMigrationDataProvider')] #[DataProvider('encryptedMigrationDataProvider')]
public function test_factory_throw_EncryptedMigrationException($payload) public function test_factory_throw_EncryptedMigrationException($payload)
{ {

View File

@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase; use Tests\TestCase;
/** /**
@ -17,9 +18,7 @@ class IsValidEmailListTest extends TestCase
{ {
use WithoutMiddleware; use WithoutMiddleware;
/** #[Test]
* @test
*/
#[DataProvider('provideValidData')] #[DataProvider('provideValidData')]
public function test_valid_data(array $data) : void public function test_valid_data(array $data) : void
{ {
@ -49,9 +48,7 @@ public static function provideValidData() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideInvalidData')] #[DataProvider('provideInvalidData')]
public function test_invalid_data(array $data) : void public function test_invalid_data(array $data) : void
{ {

View File

@ -11,6 +11,7 @@
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\ModelTestCase; use Tests\ModelTestCase;
/** /**
@ -19,9 +20,7 @@
#[CoversClass(TwoFAccount::class)] #[CoversClass(TwoFAccount::class)]
class TwoFAccountModelTest extends ModelTestCase class TwoFAccountModelTest extends ModelTestCase
{ {
/** #[Test]
* @test
*/
public function test_model_configuration() public function test_model_configuration()
{ {
$this->runConfigurationAssertions( $this->runConfigurationAssertions(
@ -43,9 +42,7 @@ public function test_model_configuration()
); );
} }
/** #[Test]
* @test
*/
#[DataProvider('provideSensitiveAttributes')] #[DataProvider('provideSensitiveAttributes')]
public function test_sensitive_attributes_are_stored_encrypted(string $attribute) public function test_sensitive_attributes_are_stored_encrypted(string $attribute)
{ {
@ -81,9 +78,7 @@ public static function provideSensitiveAttributes() : array
]; ];
} }
/** #[Test]
* @test
*/
#[DataProvider('provideSensitiveAttributes')] #[DataProvider('provideSensitiveAttributes')]
public function test_sensitive_attributes_are_returned_clear(string $attribute) public function test_sensitive_attributes_are_returned_clear(string $attribute)
{ {
@ -99,9 +94,7 @@ public function test_sensitive_attributes_are_returned_clear(string $attribute)
$this->forgetMock(SettingService::class); $this->forgetMock(SettingService::class);
} }
/** #[Test]
* @test
*/
#[DataProvider('provideSensitiveAttributes')] #[DataProvider('provideSensitiveAttributes')]
public function test_indecipherable_attributes_returns_masked_value(string $attribute) public function test_indecipherable_attributes_returns_masked_value(string $attribute)
{ {
@ -120,9 +113,7 @@ public function test_indecipherable_attributes_returns_masked_value(string $attr
$this->forgetMock(SettingService::class); $this->forgetMock(SettingService::class);
} }
/** #[Test]
* @test
*/
public function test_secret_is_uppercased_and_padded_at_setup() public function test_secret_is_uppercased_and_padded_at_setup()
{ {
$settingService = $this->mock(SettingService::class, function (MockInterface $settingService) { $settingService = $this->mock(SettingService::class, function (MockInterface $settingService) {
@ -144,9 +135,7 @@ public function test_secret_is_uppercased_and_padded_at_setup()
$this->forgetMock(SettingService::class); $this->forgetMock(SettingService::class);
} }
/** #[Test]
* @test
*/
public function test_user_relation() public function test_user_relation()
{ {
$model = new TwoFAccount(); $model = new TwoFAccount();

View File

@ -6,6 +6,7 @@
use App\Models\TwoFAccount; use App\Models\TwoFAccount;
use App\Models\User; use App\Models\User;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Tests\ModelTestCase; use Tests\ModelTestCase;
/** /**
@ -14,9 +15,7 @@
#[CoversClass(User::class)] #[CoversClass(User::class)]
class UserModelTest extends ModelTestCase class UserModelTest extends ModelTestCase
{ {
/** #[Test]
* @test
*/
public function test_model_configuration() public function test_model_configuration()
{ {
$this->runConfigurationAssertions(new User(), $this->runConfigurationAssertions(new User(),
@ -35,9 +34,7 @@ public function test_model_configuration()
); );
} }
/** #[Test]
* @test
*/
public function test_email_is_set_lowercased() public function test_email_is_set_lowercased()
{ {
$user = User::factory()->make([ $user = User::factory()->make([
@ -47,9 +44,7 @@ public function test_email_is_set_lowercased()
$this->assertEquals(strtolower('UPPERCASE@example.COM'), $user->email); $this->assertEquals(strtolower('UPPERCASE@example.COM'), $user->email);
} }
/** #[Test]
* @test
*/
public function test_twofaccounts_relation() public function test_twofaccounts_relation()
{ {
$user = new User(); $user = new User();
@ -57,9 +52,7 @@ public function test_twofaccounts_relation()
$this->assertHasManyRelation($accounts, $user, new TwoFAccount()); $this->assertHasManyRelation($accounts, $user, new TwoFAccount());
} }
/** #[Test]
* @test
*/
public function test_groups_relation() public function test_groups_relation()
{ {
$user = new User(); $user = new User();