From 7f4f7f6100e2fe1806a601a9e99afdec043a7bfd Mon Sep 17 00:00:00 2001 From: Nisha Sharma Date: Wed, 1 Apr 2026 12:29:09 +0200 Subject: [PATCH 1/2] chore: Fix Pint issues --- app/Actions/Author/SyncProjectAuthors.php | 3 +- app/Actions/Citation/SyncCitations.php | 5 +- app/Actions/Fortify/CreateNewUser.php | 2 +- app/Actions/Jetstream/DeleteUser.php | 2 +- app/Actions/Project/CreateNewProject.php | 2 +- app/Actions/Project/DeleteProject.php | 3 +- app/Actions/Project/UpdateProject.php | 5 +- app/Actions/Study/CreateNewStudy.php | 2 +- app/Actions/Study/UpdateStudy.php | 2 +- app/Console/Commands/ManageFiles.php | 6 +- app/Console/Commands/UpdateDOI.php | 2 +- app/Events/AddingProjectMember.php | 3 +- app/Events/AddingStudyMember.php | 3 +- app/Events/DraftCompleted.php | 3 +- app/Events/DraftProcessed.php | 3 +- app/Events/InvitingTeamMember.php | 3 +- app/Events/ProjectArchival.php | 3 +- app/Events/ProjectDeletion.php | 3 +- app/Events/ProjectInvite.php | 3 +- app/Events/ProjectMemberAdded.php | 3 +- app/Events/ProjectMemberRemoved.php | 3 +- app/Events/ProjectMemberUpdated.php | 3 +- app/Events/StudyInvite.php | 3 +- app/Events/StudyMemberAdded.php | 3 +- app/Events/StudyMemberRemoved.php | 3 +- app/Events/StudyMemberUpdated.php | 3 +- app/Events/StudyPublish.php | 3 +- .../API/Auth/RegisterController.php | 3 +- .../Controllers/API/Auth/UserController.php | 3 +- .../API/Auth/VerificationController.php | 6 +- app/Http/Controllers/API/DataController.php | 6 +- app/Http/Controllers/API/ELNController.php | 5 +- .../Bioschemas/BioschemasController.php | 5 +- .../Bioschemas/DataCatalogController.php | 3 +- .../Schemas/DataCite/DataCiteController.php | 5 +- app/Http/Controllers/API/SearchController.php | 3 +- .../Admin/AnnouncementController.php | 10 +- .../Controllers/Admin/UsersController.php | 30 ++-- .../Controllers/Auth/SocialController.php | 5 +- app/Http/Controllers/DownloadController.php | 2 +- app/Http/Controllers/DraftController.php | 7 +- app/Http/Controllers/FileSystemController.php | 12 +- .../ProjectInvitationController.php | 5 +- .../Controllers/ProjectMemberController.php | 7 +- .../Controllers/StudyInvitationController.php | 5 +- .../Controllers/StudyMemberController.php | 7 +- .../Controllers/SupportBubbleController.php | 3 +- app/Http/Controllers/TeamController.php | 3 +- app/Http/Middleware/XFrameOptions.php | 2 +- app/Http/Requests/SupportBubbleRequest.php | 6 +- app/Http/Resources/AuthorResource.php | 3 +- app/Http/Resources/CitationResource.php | 3 +- app/Http/Resources/DatasetResource.php | 6 +- .../Resources/FileSystemObjectResource.php | 6 +- app/Http/Resources/LicenseResource.php | 6 +- app/Http/Resources/ProjectResource.php | 6 +- app/Http/Resources/SampleResource.php | 6 +- app/Http/Resources/StudyResource.php | 6 +- app/Http/Resources/TeamResource.php | 6 +- app/Http/Resources/UserResource.php | 6 +- app/Jobs/ArchiveProject.php | 4 +- app/Jobs/ArchiveStudy.php | 4 +- app/Jobs/DeleteProjects.php | 2 +- app/Jobs/ProcessDraftELNSubmission.php | 7 +- app/Jobs/ProcessProject.php | 2 +- app/Jobs/ProcessSubmission.php | 2 +- app/Mail/ProjectInvitation.php | 2 +- app/Mail/StudyInvitation.php | 2 +- app/Mail/TeamInvitation.php | 2 +- app/Models/Author.php | 2 +- app/Models/Project.php | 7 +- app/Models/Schemas/Study.php | 28 ++-- app/Models/Study.php | 5 +- app/Providers/AppServiceProvider.php | 12 +- app/Providers/EventServiceProvider.php | 6 +- app/Services/FileIntegrityService.php | 5 +- app/Services/FileSystemObjectService.php | 9 +- bootstrap/app.php | 39 +++-- bootstrap/providers.php | 31 ++-- config/audit.php | 16 +- config/backup.php | 31 ++-- config/csp.php | 16 +- config/l5-swagger.php | 13 +- config/markable.php | 4 +- config/permission.php | 9 +- config/queue.php | 7 +- config/sanctum.php | 9 +- config/tags.php | 4 +- database/factories/AnnouncementFactory.php | 3 +- database/factories/AuthorFactory.php | 3 +- database/factories/CitationFactory.php | 3 +- database/factories/DraftFactory.php | 3 +- .../factories/FileSystemObjectFactory.php | 3 +- database/factories/LicenseFactory.php | 2 +- database/factories/NMRiumFactory.php | 15 +- .../factories/ProjectInvitationFactory.php | 3 +- database/factories/TeamInvitationFactory.php | 3 +- database/factories/TickerFactory.php | 2 +- database/factories/UserFactory.php | 2 +- database/factories/ValidationFactory.php | 3 +- ..._08_26_154527_create_permission_tables.php | 4 +- .../2023_08_25_111326_update_nmrium_table.php | 3 +- .../seeders/RolesAndPermissionsSeeder.php | 3 +- routes/web.php | 6 +- tests/API/ELNControllerTest.php | 2 +- tests/Feature/CspTest.php | 17 +- .../ELN/ChemotionMetadataServiceTest.php | 3 +- .../ProcessDraftELNSubmissionProxyTest.php | 10 +- .../ExternalServices/NFDIAAIProviderTest.php | 35 ++-- tests/Feature/FileSystemTest.php | 156 +++++++++--------- tests/Feature/ManageAuthorsTest.php | 18 +- tests/Feature/ManageCitationsTest.php | 11 +- tests/Feature/OrcidControllerTest.php | 5 +- .../Project/BasicProjectWorkflowTest.php | 5 +- .../ProjectArchivalAndDeletionTest.php | 8 +- ...rojectControllerAdditionalCoverageTest.php | 20 ++- .../Feature/Project/ProjectPublicViewTest.php | 5 +- .../Feature/Project/ProjectValidationTest.php | 9 +- tests/Feature/Project/PublishProjectTest.php | 13 +- tests/Feature/Project/UpdateProjectTest.php | 5 +- tests/Feature/RorControllerTest.php | 3 +- tests/Feature/Study/PublishStudyTest.php | 3 +- .../Feature/Study/StudyDataManagementTest.php | 3 +- tests/Feature/Study/StudyIntegrationTest.php | 19 ++- tests/Feature/Study/StudyMailTest.php | 3 +- .../Feature/Study/StudyRelationshipsTest.php | 3 +- tests/Feature/SupportBubbleTest.php | 13 +- tests/Feature/Team/TeamMailTest.php | 3 +- tests/Feature/UploadTest.php | 11 +- .../Actions/Project/AddProjectMemberTest.php | 3 +- .../Actions/Project/AssignIdentifierTest.php | 9 +- .../Actions/Project/DeleteProjectTest.php | 3 +- tests/Unit/Actions/Project/UpdateDOITest.php | 7 +- tests/Unit/Jobs/DeleteProjectsJobTest.php | 5 +- .../ProcessDraftELNSubmissionProxyTest.php | 10 +- tests/Unit/Jobs/ProcessELNSpectraTest.php | 3 +- tests/Unit/Jobs/ProcessProjectJobTest.php | 3 +- tests/Unit/Jobs/ProcessSubmissionTest.php | 22 +-- tests/Unit/Models/AuthorModelTest.php | 3 +- tests/Unit/Models/CitationModelTest.php | 6 +- tests/Unit/Models/DatasetModelTest.php | 6 +- tests/Unit/Models/DraftModelTest.php | 19 ++- .../Unit/Models/FileSystemObjectModelTest.php | 15 +- tests/Unit/Models/HasDOIModelTest.php | 52 +++--- tests/Unit/Models/HasProjectsTraitTest.php | 25 +-- tests/Unit/Models/HasStudiesTraitTest.php | 13 +- tests/Unit/Models/LicenseModelTest.php | 7 +- tests/Unit/Models/MoleculeModelTest.php | 21 ++- tests/Unit/Models/NMRiumModelTest.php | 6 +- .../Models/ProjectInvitationModelTest.php | 3 +- tests/Unit/Models/SampleModelTest.php | 15 +- .../Models/Schemas/BioschemasModelTest.php | 6 +- .../Unit/Models/StudyInvitationModelTest.php | 5 +- tests/Unit/Models/StudyModelTest.php | 6 +- tests/Unit/Models/TeamModelTest.php | 14 +- tests/Unit/Models/UserModelTest.php | 6 +- tests/Unit/Models/ValidationModelTest.php | 31 ++-- 157 files changed, 797 insertions(+), 530 deletions(-) diff --git a/app/Actions/Author/SyncProjectAuthors.php b/app/Actions/Author/SyncProjectAuthors.php index 3ef3094ee..23b4c395d 100644 --- a/app/Actions/Author/SyncProjectAuthors.php +++ b/app/Actions/Author/SyncProjectAuthors.php @@ -7,6 +7,7 @@ use App\Models\Project; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; +use Illuminate\Validation\ValidationException; class SyncProjectAuthors { @@ -18,7 +19,7 @@ public function __construct(private UpdateProject $updater) {} * @param array> $authors * @return array * - * @throws \Illuminate\Validation\ValidationException + * @throws ValidationException */ public function handle(Project $project, array $authors): array { diff --git a/app/Actions/Citation/SyncCitations.php b/app/Actions/Citation/SyncCitations.php index f33a96eb8..cedb45dd6 100644 --- a/app/Actions/Citation/SyncCitations.php +++ b/app/Actions/Citation/SyncCitations.php @@ -8,6 +8,7 @@ use App\Models\User; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; +use Illuminate\Validation\ValidationException; class SyncCitations { @@ -19,7 +20,7 @@ public function __construct(private UpdateProject $updater) {} * @param array> $citations * @return array * - * @throws \Illuminate\Validation\ValidationException + * @throws ValidationException */ public function sync(Project $project, array $citations, User $user): array { @@ -52,7 +53,7 @@ public function sync(Project $project, array $citations, User $user): array * * @param array $citationData * - * @throws \Illuminate\Validation\ValidationException + * @throws ValidationException */ private function validateCitationData(array $citationData): void { diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index de9859804..683d5755d 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -17,7 +17,7 @@ class CreateNewUser implements CreatesNewUsers /** * Create a newly registered user. * - * @return \App\Models\User + * @return User */ public function create(array $input) { diff --git a/app/Actions/Jetstream/DeleteUser.php b/app/Actions/Jetstream/DeleteUser.php index 377be6e3f..99b3054ac 100644 --- a/app/Actions/Jetstream/DeleteUser.php +++ b/app/Actions/Jetstream/DeleteUser.php @@ -11,7 +11,7 @@ class DeleteUser implements DeletesUsers /** * The team deleter implementation. * - * @var \Laravel\Jetstream\Contracts\DeletesTeams + * @var DeletesTeams */ protected $deletesTeams; diff --git a/app/Actions/Project/CreateNewProject.php b/app/Actions/Project/CreateNewProject.php index 5cb395ef6..6d3e24aad 100644 --- a/app/Actions/Project/CreateNewProject.php +++ b/app/Actions/Project/CreateNewProject.php @@ -15,7 +15,7 @@ class CreateNewProject /** * Create a project. * - * @return \App\Models\Project + * @return Project */ public function create(array $input) { diff --git a/app/Actions/Project/DeleteProject.php b/app/Actions/Project/DeleteProject.php index 5256fb912..1a5075e53 100644 --- a/app/Actions/Project/DeleteProject.php +++ b/app/Actions/Project/DeleteProject.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\User; use Illuminate\Support\Carbon; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; use Throwable; @@ -107,7 +108,7 @@ public function deleteStudy($study) /** * Delete dataset and related objects. * - * @param \Illuminate\Support\Collection $datasets + * @param Collection $datasets * @return void */ public function deleteDatasets($dataset) diff --git a/app/Actions/Project/UpdateProject.php b/app/Actions/Project/UpdateProject.php index 55cde3677..73368b885 100644 --- a/app/Actions/Project/UpdateProject.php +++ b/app/Actions/Project/UpdateProject.php @@ -3,6 +3,7 @@ namespace App\Actions\Project; use App\Models\Project; +use App\Models\User; use App\Models\Validation; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; @@ -15,7 +16,7 @@ class UpdateProject /** * Create a project. * - * @return \App\Models\Project + * @return Project */ public function update(Project $project, array $input) { @@ -190,7 +191,7 @@ public function updateContributorType(Project $project, $author_id, $role) /** * Attach citations to a project. * - * @param \App\Models\User $user + * @param User $user * @param array $citations * @return void */ diff --git a/app/Actions/Study/CreateNewStudy.php b/app/Actions/Study/CreateNewStudy.php index 2ad507e89..7ffd828ec 100644 --- a/app/Actions/Study/CreateNewStudy.php +++ b/app/Actions/Study/CreateNewStudy.php @@ -14,7 +14,7 @@ class CreateNewStudy /** * Create a study. * - * @return \App\Models\Study + * @return Study */ public function create(array $input) { diff --git a/app/Actions/Study/UpdateStudy.php b/app/Actions/Study/UpdateStudy.php index d8371b618..3aa600b5d 100644 --- a/app/Actions/Study/UpdateStudy.php +++ b/app/Actions/Study/UpdateStudy.php @@ -14,7 +14,7 @@ class UpdateStudy /** * Create a study. * - * @return \App\Models\Study + * @return Study */ public function update(Study $study, array $input) { diff --git a/app/Console/Commands/ManageFiles.php b/app/Console/Commands/ManageFiles.php index d5f3b6c73..384b984da 100644 --- a/app/Console/Commands/ManageFiles.php +++ b/app/Console/Commands/ManageFiles.php @@ -7,6 +7,8 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; +use League\Flysystem\DirectoryAttributes; +use League\Flysystem\FileAttributes; class ManageFiles extends Command { @@ -46,7 +48,7 @@ public function processFiles($path) $listing = Storage::disk(config('filesystems.default'))->listContents($path, true); foreach ($listing as $item) { $path = $item->path(); - if ($item instanceof \League\Flysystem\FileAttributes) { + if ($item instanceof FileAttributes) { $fsObject = FileSystemObject::where([ ['path', '/'.$path], ])->first(); @@ -57,7 +59,7 @@ public function processFiles($path) $fsObject->info = $fsInfo; $fsObject->save(); } - } elseif ($item instanceof \League\Flysystem\DirectoryAttributes) { + } elseif ($item instanceof DirectoryAttributes) { // echo $item->study_id; } } diff --git a/app/Console/Commands/UpdateDOI.php b/app/Console/Commands/UpdateDOI.php index 806648b43..07242cc61 100644 --- a/app/Console/Commands/UpdateDOI.php +++ b/app/Console/Commands/UpdateDOI.php @@ -27,7 +27,7 @@ class UpdateDOI extends Command /** * The DOI service instance. * - * @var \App\Services\DOI\DOIService + * @var DOIService */ protected $doiService; diff --git a/app/Events/AddingProjectMember.php b/app/Events/AddingProjectMember.php index 62dea8fad..67b6214bc 100644 --- a/app/Events/AddingProjectMember.php +++ b/app/Events/AddingProjectMember.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -33,7 +34,7 @@ public function __construct($project, $user) /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/AddingStudyMember.php b/app/Events/AddingStudyMember.php index 52299bbb9..82479f0e1 100644 --- a/app/Events/AddingStudyMember.php +++ b/app/Events/AddingStudyMember.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/DraftCompleted.php b/app/Events/DraftCompleted.php index 9611c0545..ef6f6ca9f 100644 --- a/app/Events/DraftCompleted.php +++ b/app/Events/DraftCompleted.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/DraftProcessed.php b/app/Events/DraftProcessed.php index 8d37cc89d..c7592fe05 100644 --- a/app/Events/DraftProcessed.php +++ b/app/Events/DraftProcessed.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Foundation\Events\Dispatchable; @@ -28,7 +29,7 @@ public function __construct($project, $sendTo) /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/InvitingTeamMember.php b/app/Events/InvitingTeamMember.php index b1962dee9..8ff8dcf95 100644 --- a/app/Events/InvitingTeamMember.php +++ b/app/Events/InvitingTeamMember.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/ProjectArchival.php b/app/Events/ProjectArchival.php index 25805ef89..8c40ce03c 100644 --- a/app/Events/ProjectArchival.php +++ b/app/Events/ProjectArchival.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Foundation\Events\Dispatchable; @@ -26,7 +27,7 @@ public function __construct($project, $sendTo) /** * Get the channels the event should broadcast on. * - * @return array + * @return array */ public function broadcastOn(): array { diff --git a/app/Events/ProjectDeletion.php b/app/Events/ProjectDeletion.php index 2ed4b9010..642079d15 100644 --- a/app/Events/ProjectDeletion.php +++ b/app/Events/ProjectDeletion.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Foundation\Events\Dispatchable; @@ -26,7 +27,7 @@ public function __construct($project, $sendTo) /** * Get the channels the event should broadcast on. * - * @return array + * @return array */ public function broadcastOn(): array { diff --git a/app/Events/ProjectInvite.php b/app/Events/ProjectInvite.php index 1097d3be3..22e8eba70 100644 --- a/app/Events/ProjectInvite.php +++ b/app/Events/ProjectInvite.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Foundation\Events\Dispatchable; @@ -26,7 +27,7 @@ public function __construct($invitedUser, $invitation) /** * Get the channels the event should broadcast on. * - * @return array + * @return array */ public function broadcastOn(): array { diff --git a/app/Events/ProjectMemberAdded.php b/app/Events/ProjectMemberAdded.php index 54e5e9a2e..026318aa0 100644 --- a/app/Events/ProjectMemberAdded.php +++ b/app/Events/ProjectMemberAdded.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -33,7 +34,7 @@ public function __construct($project, $user) /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/ProjectMemberRemoved.php b/app/Events/ProjectMemberRemoved.php index 44405cf72..f683af1e9 100644 --- a/app/Events/ProjectMemberRemoved.php +++ b/app/Events/ProjectMemberRemoved.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/ProjectMemberUpdated.php b/app/Events/ProjectMemberUpdated.php index 2fcf4c1d4..1cd4074bf 100644 --- a/app/Events/ProjectMemberUpdated.php +++ b/app/Events/ProjectMemberUpdated.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/StudyInvite.php b/app/Events/StudyInvite.php index 5f386b859..26daa12ad 100644 --- a/app/Events/StudyInvite.php +++ b/app/Events/StudyInvite.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Foundation\Events\Dispatchable; @@ -26,7 +27,7 @@ public function __construct($invitedUser, $invitation) /** * Get the channels the event should broadcast on. * - * @return array + * @return array */ public function broadcastOn(): array { diff --git a/app/Events/StudyMemberAdded.php b/app/Events/StudyMemberAdded.php index 95885ce17..e94b8613b 100644 --- a/app/Events/StudyMemberAdded.php +++ b/app/Events/StudyMemberAdded.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/StudyMemberRemoved.php b/app/Events/StudyMemberRemoved.php index a7630bdf7..a51259bb2 100644 --- a/app/Events/StudyMemberRemoved.php +++ b/app/Events/StudyMemberRemoved.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/StudyMemberUpdated.php b/app/Events/StudyMemberUpdated.php index b7bb1ebe8..e785b2491 100644 --- a/app/Events/StudyMemberUpdated.php +++ b/app/Events/StudyMemberUpdated.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Foundation\Events\Dispatchable; @@ -24,7 +25,7 @@ public function __construct() /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Events/StudyPublish.php b/app/Events/StudyPublish.php index a751cd325..9078d942d 100644 --- a/app/Events/StudyPublish.php +++ b/app/Events/StudyPublish.php @@ -2,6 +2,7 @@ namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Foundation\Events\Dispatchable; @@ -28,7 +29,7 @@ public function __construct($studies, $sendTo) /** * Get the channels the event should broadcast on. * - * @return \Illuminate\Broadcasting\Channel|array + * @return Channel|array */ public function broadcastOn(): array { diff --git a/app/Http/Controllers/API/Auth/RegisterController.php b/app/Http/Controllers/API/Auth/RegisterController.php index 6ab550c9f..17ae0b2c5 100644 --- a/app/Http/Controllers/API/Auth/RegisterController.php +++ b/app/Http/Controllers/API/Auth/RegisterController.php @@ -6,6 +6,7 @@ use App\Models\Team; use App\Models\User; use Illuminate\Auth\Events\Verified; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; @@ -258,7 +259,7 @@ class RegisterController extends Controller * * Register new user account * - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ public function register(Request $request) { diff --git a/app/Http/Controllers/API/Auth/UserController.php b/app/Http/Controllers/API/Auth/UserController.php index 16d1213e1..17830bf8d 100644 --- a/app/Http/Controllers/API/Auth/UserController.php +++ b/app/Http/Controllers/API/Auth/UserController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\API\Auth; use App\Http\Controllers\Controller; +use App\Models\User; use Illuminate\Http\Request; class UserController extends Controller @@ -214,7 +215,7 @@ class UserController extends Controller * * Get current authenticated user information * - * @return \App\Models\User + * @return User */ public function info(Request $request) { diff --git a/app/Http/Controllers/API/Auth/VerificationController.php b/app/Http/Controllers/API/Auth/VerificationController.php index b9548c547..75fa26694 100644 --- a/app/Http/Controllers/API/Auth/VerificationController.php +++ b/app/Http/Controllers/API/Auth/VerificationController.php @@ -7,6 +7,8 @@ use Auth; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Events\Verified; +use Illuminate\Http\JsonResponse; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; class VerificationController extends Controller @@ -129,7 +131,7 @@ class VerificationController extends Controller * Verify user email address using signed URL * * @param int $user_id - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse + * @return RedirectResponse|JsonResponse */ public function verify($user_id, Request $request) { @@ -275,7 +277,7 @@ public function verify($user_id, Request $request) * * Resend email verification link * - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ public function resend() { diff --git a/app/Http/Controllers/API/DataController.php b/app/Http/Controllers/API/DataController.php index 84e432366..2a1aaccd5 100644 --- a/app/Http/Controllers/API/DataController.php +++ b/app/Http/Controllers/API/DataController.php @@ -9,7 +9,9 @@ use App\Models\Dataset; use App\Models\Project; use App\Models\Study; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Http\Resources\Json\AnonymousResourceCollection; use Spatie\QueryBuilder\QueryBuilder; class DataController extends Controller @@ -244,7 +246,7 @@ class DataController extends Controller * and includes Bioschemas.org metadata for enhanced discoverability. * * @param string $model The data model type (projects|samples|datasets) - * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection + * @return AnonymousResourceCollection */ public function all(Request $request, $model) { @@ -474,7 +476,7 @@ public function all(Request $request, $model) * - Usage statistics and engagement metrics * * @param string $id NMRXIV identifier (P123, S456, D789) - * @return \App\Http\Resources\ProjectResource|\App\Http\Resources\StudyResource|\App\Http\Resources\DatasetResource|\Illuminate\Http\JsonResponse + * @return ProjectResource|StudyResource|DatasetResource|JsonResponse */ public function id(Request $request, $id) { diff --git a/app/Http/Controllers/API/ELNController.php b/app/Http/Controllers/API/ELNController.php index b9b2f7722..bb7cd1ca3 100644 --- a/app/Http/Controllers/API/ELNController.php +++ b/app/Http/Controllers/API/ELNController.php @@ -11,6 +11,7 @@ use App\Services\ChemotionRepositoryTrackerService; use Carbon\Carbon; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; @@ -208,7 +209,7 @@ class ELNController extends Controller * Handle file upload for a specific ELN entry * * @param string $eln - * @return \Illuminate\Http\Response + * @return Response */ public function upload($eln, Request $request) { @@ -541,7 +542,7 @@ public function upload($eln, Request $request) * * @param string $eln * @param string $external_id - * @return \Illuminate\Http\Response + * @return Response */ public function status($eln, $external_id) { diff --git a/app/Http/Controllers/API/Schemas/Bioschemas/BioschemasController.php b/app/Http/Controllers/API/Schemas/Bioschemas/BioschemasController.php index 3e0bf0937..f0fc20ded 100644 --- a/app/Http/Controllers/API/Schemas/Bioschemas/BioschemasController.php +++ b/app/Http/Controllers/API/Schemas/Bioschemas/BioschemasController.php @@ -12,6 +12,7 @@ use App\Models\User; use Carbon\Carbon; use Illuminate\Auth\Access\AuthorizationException; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use Spatie\SchemaOrg\Schema; @@ -240,7 +241,7 @@ class BioschemasController extends Controller * * @param string $username NMRXIV username * @param string $projectName Project slug identifier - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ // public function modelSchemaByName(Request $request, $username, $projectName, $studyName = null, $datasetName = null) @@ -487,7 +488,7 @@ class BioschemasController extends Controller * - Scientific workflow interoperability * * @param string $identifier NMRXIV public identifier (P123, S456, D789) - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ public function modelSchemaByID(Request $request, $identifier) { diff --git a/app/Http/Controllers/API/Schemas/Bioschemas/DataCatalogController.php b/app/Http/Controllers/API/Schemas/Bioschemas/DataCatalogController.php index d20c39fd1..29d8688a8 100644 --- a/app/Http/Controllers/API/Schemas/Bioschemas/DataCatalogController.php +++ b/app/Http/Controllers/API/Schemas/Bioschemas/DataCatalogController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\API\Schemas\Bioschemas; use App\Http\Controllers\Controller; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; use Spatie\SchemaOrg\Schema; @@ -246,7 +247,7 @@ class DataCatalogController extends Controller * - Compliance with funding agency data sharing requirements * - Support for systematic reviews and meta-analyses in chemistry * - * @return \Illuminate\Http\JsonResponse DataCatalog schema representing NMRXIV repository + * @return JsonResponse DataCatalog schema representing NMRXIV repository */ public function dataCatalogSchema(Request $request) { diff --git a/app/Http/Controllers/API/Schemas/DataCite/DataCiteController.php b/app/Http/Controllers/API/Schemas/DataCite/DataCiteController.php index 0c0f3dfcc..3a515f089 100644 --- a/app/Http/Controllers/API/Schemas/DataCite/DataCiteController.php +++ b/app/Http/Controllers/API/Schemas/DataCite/DataCiteController.php @@ -7,6 +7,7 @@ use App\Models\Project; use App\Models\Study; use App\Models\User; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class DataCiteController extends Controller @@ -363,7 +364,7 @@ class DataCiteController extends Controller * * @param string $username NMRXIV username * @param string $projectName Project slug identifier - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ // public function modelSchemaByName(Request $request, $username, $projectName, $studyName = null, $datasetName = null) @@ -620,7 +621,7 @@ class DataCiteController extends Controller * - **Datasets**: Specific NMR experiments and spectroscopic data * * @param string $identifier NMRXIV public identifier (P123, S456, D789) - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ public function modelSchemaByID(Request $request, $identifier) { diff --git a/app/Http/Controllers/API/SearchController.php b/app/Http/Controllers/API/SearchController.php index c164e7363..6d780d316 100644 --- a/app/Http/Controllers/API/SearchController.php +++ b/app/Http/Controllers/API/SearchController.php @@ -5,6 +5,7 @@ use App\Http\Controllers\Controller; use App\Models\Molecule; use Illuminate\Database\QueryException; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Facades\DB; @@ -225,7 +226,7 @@ class SearchController extends Controller * - **Tags**: Classification-based search * - **Filters**: Property-based filtering * - * @return \Illuminate\Pagination\LengthAwarePaginator|\Illuminate\Http\JsonResponse + * @return LengthAwarePaginator|JsonResponse */ public function search(Request $request) { diff --git a/app/Http/Controllers/Admin/AnnouncementController.php b/app/Http/Controllers/Admin/AnnouncementController.php index e3d13cea1..25d6d2d1d 100644 --- a/app/Http/Controllers/Admin/AnnouncementController.php +++ b/app/Http/Controllers/Admin/AnnouncementController.php @@ -6,16 +6,18 @@ use App\Models\Announcement; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use Inertia\Inertia; +use Pages\Announcement\Index; class AnnouncementController extends Controller { /** * Show all the list of Announcements created. * - * @return \Pages\Announcement\Index + * @return Index */ public function index(Request $request) { @@ -44,7 +46,7 @@ public function index(Request $request) /** * Create the new entry for the announcement. * - * @return \Illuminate\Http\Response + * @return Response */ public function create(Request $request) { @@ -84,7 +86,7 @@ public function create(Request $request) /** * Update the specified announcement in the storage. * - * @return \Illuminate\Http\Response + * @return Response */ public function update(Request $request, Announcement $announcement) { @@ -117,7 +119,7 @@ public function update(Request $request, Announcement $announcement) /** * Remove the specified announcement from the storage. * - * @return \Illuminate\Http\Response + * @return Response */ public function destroy(Request $request, Announcement $announcement) { diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index b351a275e..d69fa5c36 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -4,15 +4,21 @@ use App\Actions\Fortify\CreateNewUser; use App\Actions\Fortify\PasswordValidationRules; +use App\Actions\Fortify\UpdateUserProfileInformation; use App\Http\Controllers\Controller; use App\Models\User; use Illuminate\Auth\Events\Registered; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Inertia\Inertia; use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; +use Pages\Console\Users\Create; +use Pages\Console\Users\Edit; +use Pages\Console\Users\Index; use Spatie\Permission\Models\Role; class UsersController extends Controller @@ -22,7 +28,7 @@ class UsersController extends Controller /** * Render the index page with list of users. * - * @return \Pages\Console\Users\Index + * @return Index */ public function index(Request $request) { @@ -55,7 +61,7 @@ public function index(Request $request) /** * Render the create user page. * - * @return \Pages\Console\Users\Create + * @return Create */ public function create() { @@ -71,7 +77,7 @@ public function create() /** * Store the newly created user. * - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function store(Request $request, CreateNewUser $creator) { @@ -84,7 +90,7 @@ public function store(Request $request, CreateNewUser $creator) /** * Render the edit user page. * - * @return \Pages\Console\Users\Edit + * @return Edit */ public function edit(User $user) { @@ -107,8 +113,8 @@ public function edit(User $user) /** * Save the updated user info. * - * @param \App\Actions\Fortify\UpdateUserProfileInformation $updater - * @return \Illuminate\Http\RedirectResponse + * @param UpdateUserProfileInformation $updater + * @return RedirectResponse */ public function update(User $user, Request $request, UpdatesUserProfileInformation $updater) { @@ -120,7 +126,7 @@ public function update(User $user, Request $request, UpdatesUserProfileInformati /** * Save the updated password for the user. * - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function updatePassword(User $user, Request $request) { @@ -138,7 +144,7 @@ public function updatePassword(User $user, Request $request) /** * Save the updated role for the user. * - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function updateRole(User $user, Request $request) { @@ -164,7 +170,7 @@ public function updateRole(User $user, Request $request) /** * Check if user has password. * - * @return \Illuminate\Http\Response + * @return Response */ public function checkPassword(Request $request) { @@ -182,7 +188,7 @@ public function checkPassword(Request $request) /** * Delete the profile photo. * - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function destroyPhoto(User $user, Request $request) { @@ -195,7 +201,7 @@ public function destroyPhoto(User $user, Request $request) * Mark notification as read. * * @param int $id - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function markNotificationAsRead(User $user, Request $request) { @@ -212,7 +218,7 @@ public function markNotificationAsRead(User $user, Request $request) * Mark all notification as read. * * @param User $user - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function markAllNotificationAsRead(Request $request) { diff --git a/app/Http/Controllers/Auth/SocialController.php b/app/Http/Controllers/Auth/SocialController.php index 754f7cbe2..1619de34d 100644 --- a/app/Http/Controllers/Auth/SocialController.php +++ b/app/Http/Controllers/Auth/SocialController.php @@ -7,6 +7,7 @@ use App\Models\Team; use App\Models\User; use Illuminate\Auth\Events\Registered; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Redirect; use Laravel\Socialite\Facades\Socialite; @@ -17,7 +18,7 @@ class SocialController extends Controller /** * Redirect the user to the GitHub authentication page. * - * @return \Illuminate\Http\Response + * @return Response */ public function redirectToProvider($service) { @@ -31,7 +32,7 @@ public function redirectToProvider($service) /** * Obtain the user information from GitHub. * - * @return \Illuminate\Http\Response + * @return Response */ public function handleProviderCallback($service) { diff --git a/app/Http/Controllers/DownloadController.php b/app/Http/Controllers/DownloadController.php index 1a62737ef..9c79961ac 100644 --- a/app/Http/Controllers/DownloadController.php +++ b/app/Http/Controllers/DownloadController.php @@ -164,7 +164,7 @@ function () use ($s3keys, $bucket, $fsObj) { /** * Get the S3 storage client instance. * - * @return \Aws\S3\S3Client + * @return S3Client */ protected function storageClient() { diff --git a/app/Http/Controllers/DraftController.php b/app/Http/Controllers/DraftController.php index 603ec3c0c..a3be54cba 100644 --- a/app/Http/Controllers/DraftController.php +++ b/app/Http/Controllers/DraftController.php @@ -9,8 +9,11 @@ use App\Models\Draft; use App\Models\FileSystemObject; use App\Models\Project; +use App\Models\User; use Illuminate\Http\JsonResponse; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; /** @@ -52,7 +55,7 @@ public function all(Request $request): JsonResponse /** * Process draft and convert to project structure. * - * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse + * @return Response|JsonResponse|RedirectResponse */ public function process(Request $request, Draft $draft) { @@ -86,7 +89,7 @@ public function missingFiles(Request $request, Draft $draft): JsonResponse */ public function show(Request $request, Draft $draft): JsonResponse { - /** @var \App\Models\User $user */ + /** @var User $user */ $user = Auth::user(); [$user_id] = $user->getUserTeamData(); diff --git a/app/Http/Controllers/FileSystemController.php b/app/Http/Controllers/FileSystemController.php index 7a9857cad..1503bf9bc 100644 --- a/app/Http/Controllers/FileSystemController.php +++ b/app/Http/Controllers/FileSystemController.php @@ -9,10 +9,12 @@ use App\Services\ELNMetadataServiceFactory; use App\Services\FileSystemObjectService; use App\Services\StorageSignedUrlService; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; +use Illuminate\Validation\ValidationException; /** * Handle file system operations and signed URL generation for file uploads. @@ -30,8 +32,8 @@ public function __construct( /** * Generate signed URLs for draft file uploads. * - * @throws \Illuminate\Validation\ValidationException - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * @throws ValidationException + * @throws ModelNotFoundException */ public function signedDraftStorageURL(Request $request): JsonResponse { @@ -71,8 +73,8 @@ public function signedDraftStorageURL(Request $request): JsonResponse /** * Generate signed URLs for project file uploads. * - * @throws \Illuminate\Validation\ValidationException - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * @throws ValidationException + * @throws ModelNotFoundException */ public function signedStorageURL(Request $request): JsonResponse { @@ -108,7 +110,7 @@ public function signedStorageURL(Request $request): JsonResponse /** * Delete a filesystem object and all its children recursively. * - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * @throws ModelNotFoundException */ public function deleteFSO(Request $request, Draft $draft, FileSystemObject $filesystemobject): JsonResponse { diff --git a/app/Http/Controllers/ProjectInvitationController.php b/app/Http/Controllers/ProjectInvitationController.php index 28dc8adfc..37b157c06 100644 --- a/app/Http/Controllers/ProjectInvitationController.php +++ b/app/Http/Controllers/ProjectInvitationController.php @@ -5,6 +5,7 @@ use App\Actions\Project\AddProjectMember; use App\Models\ProjectInvitation; use Illuminate\Auth\Access\AuthorizationException; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; @@ -14,7 +15,7 @@ class ProjectInvitationController extends Controller * Accept a project invitation. * * @param \Laravel\Jetstream\ProjectInvitation $invitation - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function acceptInvitation(Request $request, ProjectInvitation $invitation) { @@ -36,7 +37,7 @@ public function acceptInvitation(Request $request, ProjectInvitation $invitation * Cancel the given project invitation. * * @param \Laravel\Jetstream\ProjectInvitation $invitation - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function destroyInvitation(Request $request, ProjectInvitation $invitation) { diff --git a/app/Http/Controllers/ProjectMemberController.php b/app/Http/Controllers/ProjectMemberController.php index a347c4148..a81106b2d 100644 --- a/app/Http/Controllers/ProjectMemberController.php +++ b/app/Http/Controllers/ProjectMemberController.php @@ -7,6 +7,7 @@ use App\Actions\Project\UpdateProjectMemberRole; use App\Models\Project; use App\Models\User; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; class ProjectMemberController extends Controller @@ -15,7 +16,7 @@ class ProjectMemberController extends Controller * Add a new team member to a project. * * @param int $projectId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function memberStore(Request $request, $projectId) { @@ -37,7 +38,7 @@ public function memberStore(Request $request, $projectId) * * @param int $projectId * @param int $userId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function updateMemberRole(Request $request, $projectId, $userId) { @@ -56,7 +57,7 @@ public function updateMemberRole(Request $request, $projectId, $userId) * * @param int $projectId * @param int $userId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function removeMember(Request $request, $projectId, $userId) { diff --git a/app/Http/Controllers/StudyInvitationController.php b/app/Http/Controllers/StudyInvitationController.php index 809895185..7461355cc 100644 --- a/app/Http/Controllers/StudyInvitationController.php +++ b/app/Http/Controllers/StudyInvitationController.php @@ -5,6 +5,7 @@ use App\Actions\Study\AddStudyMember; use App\Models\StudyInvitation; use Illuminate\Auth\Access\AuthorizationException; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Gate; @@ -14,7 +15,7 @@ class StudyInvitationController extends Controller * Accept a study invitation. * * @param \Laravel\Jetstream\StudyInvitation $invitation - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function acceptInvitation(Request $request, StudyInvitation $invitation) { @@ -36,7 +37,7 @@ public function acceptInvitation(Request $request, StudyInvitation $invitation) * Cancel the given study invitation. * * @param \Laravel\Jetstream\StudyInvitation $invitation - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function destroyInvitation(Request $request, StudyInvitation $invitation) { diff --git a/app/Http/Controllers/StudyMemberController.php b/app/Http/Controllers/StudyMemberController.php index fe68dfa8a..3e9b61753 100644 --- a/app/Http/Controllers/StudyMemberController.php +++ b/app/Http/Controllers/StudyMemberController.php @@ -7,6 +7,7 @@ use App\Actions\Study\UpdateStudyMemberRole; use App\Models\Study; use App\Models\User; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; class StudyMemberController extends Controller @@ -15,7 +16,7 @@ class StudyMemberController extends Controller * Add a new team member to a study. * * @param int $studyId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function memberStore(Request $request, $studyId) { @@ -37,7 +38,7 @@ public function memberStore(Request $request, $studyId) * * @param int $studyId * @param int $userId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function updateMemberRole(Request $request, $studyId, $userId) { @@ -56,7 +57,7 @@ public function updateMemberRole(Request $request, $studyId, $userId) * * @param int $studyId * @param int $userId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function removeMember(Request $request, $studyId, $userId) { diff --git a/app/Http/Controllers/SupportBubbleController.php b/app/Http/Controllers/SupportBubbleController.php index a9a07a76f..96c417ef3 100644 --- a/app/Http/Controllers/SupportBubbleController.php +++ b/app/Http/Controllers/SupportBubbleController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Requests\SupportBubbleRequest; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Response; use Illuminate\Support\Facades\Log; use Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent; @@ -12,7 +13,7 @@ class SupportBubbleController extends Controller /** * Handle support bubble form submission */ - public function submit(SupportBubbleRequest $request): Response|\Illuminate\Http\JsonResponse + public function submit(SupportBubbleRequest $request): Response|JsonResponse { try { // Fire the event diff --git a/app/Http/Controllers/TeamController.php b/app/Http/Controllers/TeamController.php index 5effac6eb..4bc5ea5e1 100644 --- a/app/Http/Controllers/TeamController.php +++ b/app/Http/Controllers/TeamController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Contracts\Auth\StatefulGuard; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; use Laravel\Fortify\Actions\ConfirmPassword; @@ -19,7 +20,7 @@ class TeamController extends Controller * Delete the given team. * * @param int $teamId - * @return \Illuminate\Http\RedirectResponse + * @return RedirectResponse */ public function destroy(Request $request, StatefulGuard $guard, $teamId) { diff --git a/app/Http/Middleware/XFrameOptions.php b/app/Http/Middleware/XFrameOptions.php index 9b4e237f6..b22d47e1b 100644 --- a/app/Http/Middleware/XFrameOptions.php +++ b/app/Http/Middleware/XFrameOptions.php @@ -11,7 +11,7 @@ class XFrameOptions /** * Handle an incoming request. * - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param Closure(Request): (Response) $next */ public function handle(Request $request, Closure $next): Response { diff --git a/app/Http/Requests/SupportBubbleRequest.php b/app/Http/Requests/SupportBubbleRequest.php index 85a3e0e11..f44e40c99 100644 --- a/app/Http/Requests/SupportBubbleRequest.php +++ b/app/Http/Requests/SupportBubbleRequest.php @@ -3,6 +3,8 @@ namespace App\Http\Requests; use App\Rules\RecaptchaRule; +use Illuminate\Contracts\Validation\ValidationRule; +use Illuminate\Contracts\Validation\Validator; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Log; @@ -19,7 +21,7 @@ public function authorize(): bool /** * Get the validation rules that apply to the request. * - * @return array|string> + * @return array|string> */ public function rules(): array { @@ -233,7 +235,7 @@ protected function isGibberishEmail(string $username): bool /** * Handle a failed validation attempt. */ - protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator): void + protected function failedValidation(Validator $validator): void { // Log suspicious attempts for monitoring if ($this->containsSpamIndicators()) { diff --git a/app/Http/Resources/AuthorResource.php b/app/Http/Resources/AuthorResource.php index a0e7da409..ed96439cf 100644 --- a/app/Http/Resources/AuthorResource.php +++ b/app/Http/Resources/AuthorResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class AuthorResource extends JsonResource @@ -9,7 +10,7 @@ class AuthorResource extends JsonResource /** * Transform the author resource into an array. * - * @param \Illuminate\Http\Request $request + * @param Request $request * @return array */ public function toArray($request): array diff --git a/app/Http/Resources/CitationResource.php b/app/Http/Resources/CitationResource.php index b52080b65..1c404c5b0 100644 --- a/app/Http/Resources/CitationResource.php +++ b/app/Http/Resources/CitationResource.php @@ -2,6 +2,7 @@ namespace App\Http\Resources; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class CitationResource extends JsonResource @@ -9,7 +10,7 @@ class CitationResource extends JsonResource /** * Transform the citation resource into an array. * - * @param \Illuminate\Http\Request $request + * @param Request $request * @return array */ public function toArray($request): array diff --git a/app/Http/Resources/DatasetResource.php b/app/Http/Resources/DatasetResource.php index f43983eb8..40e9c85c3 100644 --- a/app/Http/Resources/DatasetResource.php +++ b/app/Http/Resources/DatasetResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class DatasetResource extends JsonResource @@ -23,8 +25,8 @@ public function lite(bool $lite, ?array $properties = []): self /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/FileSystemObjectResource.php b/app/Http/Resources/FileSystemObjectResource.php index fce0a8e7d..c2e76698e 100644 --- a/app/Http/Resources/FileSystemObjectResource.php +++ b/app/Http/Resources/FileSystemObjectResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class FileSystemObjectResource extends JsonResource @@ -9,8 +11,8 @@ class FileSystemObjectResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/LicenseResource.php b/app/Http/Resources/LicenseResource.php index 05d4e667b..c75e6ed91 100644 --- a/app/Http/Resources/LicenseResource.php +++ b/app/Http/Resources/LicenseResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class LicenseResource extends JsonResource @@ -9,8 +11,8 @@ class LicenseResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/ProjectResource.php b/app/Http/Resources/ProjectResource.php index 793430c34..ae30e69f3 100644 --- a/app/Http/Resources/ProjectResource.php +++ b/app/Http/Resources/ProjectResource.php @@ -3,6 +3,8 @@ namespace App\Http\Resources; use App\Models\FileSystemObject; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class ProjectResource extends JsonResource @@ -24,8 +26,8 @@ public function lite(bool $lite, ?array $properties = []): self /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/SampleResource.php b/app/Http/Resources/SampleResource.php index 46922821d..acd4ede8e 100644 --- a/app/Http/Resources/SampleResource.php +++ b/app/Http/Resources/SampleResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class SampleResource extends JsonResource @@ -9,8 +11,8 @@ class SampleResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/StudyResource.php b/app/Http/Resources/StudyResource.php index 084a93b85..1d05e3974 100644 --- a/app/Http/Resources/StudyResource.php +++ b/app/Http/Resources/StudyResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class StudyResource extends JsonResource @@ -23,8 +25,8 @@ public function lite(bool $lite, ?array $properties = []): self /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/TeamResource.php b/app/Http/Resources/TeamResource.php index fd1c38c6f..378aba3bc 100644 --- a/app/Http/Resources/TeamResource.php +++ b/app/Http/Resources/TeamResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class TeamResource extends JsonResource @@ -9,8 +11,8 @@ class TeamResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index f1d59d26c..27ce26607 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -2,6 +2,8 @@ namespace App\Http\Resources; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; class UserResource extends JsonResource @@ -9,8 +11,8 @@ class UserResource extends JsonResource /** * Transform the resource into an array. * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable + * @param Request $request + * @return array|Arrayable|\JsonSerializable */ public function toArray($request): array { diff --git a/app/Jobs/ArchiveProject.php b/app/Jobs/ArchiveProject.php index 46d8739af..52c01387c 100644 --- a/app/Jobs/ArchiveProject.php +++ b/app/Jobs/ArchiveProject.php @@ -24,7 +24,7 @@ class ArchiveProject implements ShouldBeUnique, ShouldQueue /** * The project instance. * - * @var \App\Models\Project + * @var Project */ public $project; @@ -181,7 +181,7 @@ public function handle(): void /** * Get the S3 storage client instance. * - * @return \Aws\S3\S3Client + * @return S3Client */ protected function storageClient() { diff --git a/app/Jobs/ArchiveStudy.php b/app/Jobs/ArchiveStudy.php index 2a0d53b37..5982c4715 100644 --- a/app/Jobs/ArchiveStudy.php +++ b/app/Jobs/ArchiveStudy.php @@ -24,7 +24,7 @@ class ArchiveStudy implements ShouldBeUnique, ShouldQueue /** * The project instance. * - * @var \App\Models\Project + * @var Project */ public $project; @@ -318,7 +318,7 @@ private function generateS3Url(string $filePath, string $filesystemDriver, strin /** * Get the S3 storage client instance. * - * @return \Aws\S3\S3Client + * @return S3Client */ protected function storageClient() { diff --git a/app/Jobs/DeleteProjects.php b/app/Jobs/DeleteProjects.php index bc1fb7f77..5855aeae3 100644 --- a/app/Jobs/DeleteProjects.php +++ b/app/Jobs/DeleteProjects.php @@ -18,7 +18,7 @@ class DeleteProjects implements ShouldQueue /** * The project instance. * - * @var \App\Models\Project + * @var Project */ private $project; diff --git a/app/Jobs/ProcessDraftELNSubmission.php b/app/Jobs/ProcessDraftELNSubmission.php index 5356e2037..50182fd86 100644 --- a/app/Jobs/ProcessDraftELNSubmission.php +++ b/app/Jobs/ProcessDraftELNSubmission.php @@ -6,6 +6,7 @@ use App\Actions\Draft\DraftProcessingLogger; use App\Actions\Draft\ProcessDraft; use App\Http\Controllers\FileSystemController; +use App\Models\Author; use App\Models\Draft; use App\Models\FileSystemObject; use App\Models\License; @@ -518,18 +519,18 @@ private function syncStudyAuthors($study, array $authorData, DraftProcessingLogg $author = null; if (! empty($data['orcid_id'])) { - $author = \App\Models\Author::where('orcid_id', $data['orcid_id'])->first(); + $author = Author::where('orcid_id', $data['orcid_id'])->first(); } if (! $author) { - $author = \App\Models\Author::where('given_name', $data['given_name']) + $author = Author::where('given_name', $data['given_name']) ->where('family_name', $data['family_name']) ->first(); } // Create if not found if (! $author) { - $author = \App\Models\Author::create([ + $author = Author::create([ 'given_name' => $data['given_name'], 'family_name' => $data['family_name'], 'email_id' => $data['email_id'], diff --git a/app/Jobs/ProcessProject.php b/app/Jobs/ProcessProject.php index c8f9f52e1..3f3a98b8c 100644 --- a/app/Jobs/ProcessProject.php +++ b/app/Jobs/ProcessProject.php @@ -27,7 +27,7 @@ class ProcessProject implements ShouldBeUnique, ShouldQueue /** * The project instance. * - * @var \App\Models\Project + * @var Project */ public $project; diff --git a/app/Jobs/ProcessSubmission.php b/app/Jobs/ProcessSubmission.php index fb7e7c1e3..44653dcc9 100644 --- a/app/Jobs/ProcessSubmission.php +++ b/app/Jobs/ProcessSubmission.php @@ -27,7 +27,7 @@ class ProcessSubmission implements ShouldBeUnique, ShouldQueue /** * The project instance. * - * @var \App\Models\Project + * @var Project */ public $project; diff --git a/app/Mail/ProjectInvitation.php b/app/Mail/ProjectInvitation.php index 409c92759..bba952be4 100644 --- a/app/Mail/ProjectInvitation.php +++ b/app/Mail/ProjectInvitation.php @@ -16,7 +16,7 @@ class ProjectInvitation extends Mailable implements ShouldQueue /** * The project invitation instance. * - * @var \App\Models\ProjectInvitation + * @var ProjectInvitationModel */ public $invitation; diff --git a/app/Mail/StudyInvitation.php b/app/Mail/StudyInvitation.php index 12b10dbde..41e91f22a 100644 --- a/app/Mail/StudyInvitation.php +++ b/app/Mail/StudyInvitation.php @@ -16,7 +16,7 @@ class StudyInvitation extends Mailable implements ShouldQueue /** * The study invitation instance. * - * @var \App\Models\StudyInvitation + * @var StudyInvitationModel */ public $invitation; diff --git a/app/Mail/TeamInvitation.php b/app/Mail/TeamInvitation.php index e1488a363..dbbf63798 100644 --- a/app/Mail/TeamInvitation.php +++ b/app/Mail/TeamInvitation.php @@ -16,7 +16,7 @@ class TeamInvitation extends Mailable implements ShouldQueue /** * The study invitation instance. * - * @var \App\Models\TeamInvitation + * @var TeamInvitationModel */ public $invitation; diff --git a/app/Models/Author.php b/app/Models/Author.php index e59a95773..16352f267 100644 --- a/app/Models/Author.php +++ b/app/Models/Author.php @@ -13,7 +13,7 @@ class Author extends Model /** * Projects that belongs to authors. * - * @return \Illuminate\Database\Eloquent\Relations\belongsToMany + * @return BelongsToMany */ protected $fillable = [ 'title', diff --git a/app/Models/Project.php b/app/Models/Project.php index 797835165..e573e7773 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -16,6 +16,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Notification; use Laravel\Scout\Searchable; use Maize\Markable\Markable; @@ -162,7 +163,7 @@ public function owner(): BelongsTo /** * Get all of the project's users including its owner. * - * @return \Illuminate\Support\Collection + * @return Collection */ public function allUsers() { @@ -183,7 +184,7 @@ public function users(): BelongsToMany /** * Determine if the given user belongs to the project. * - * @param \App\Models\User $user + * @param User $user * @return bool */ public function hasUser($user) @@ -256,7 +257,7 @@ public function projectInvitations(): HasMany /** * Remove the given user from the project. * - * @param \App\Models\User $user + * @param User $user * @return void */ public function removeUser($user) diff --git a/app/Models/Schemas/Study.php b/app/Models/Schemas/Study.php index c9d7b5976..05284317b 100644 --- a/app/Models/Schemas/Study.php +++ b/app/Models/Schemas/Study.php @@ -3,6 +3,14 @@ namespace App\Models\Schemas; use Spatie\SchemaOrg\BaseType; +use Spatie\SchemaOrg\Contracts\BioChemEntityContract; +use Spatie\SchemaOrg\Contracts\CreativeWorkContract; +use Spatie\SchemaOrg\Contracts\DefinedTermContract; +use Spatie\SchemaOrg\Contracts\MedicalEntityContract; +use Spatie\SchemaOrg\Contracts\OrganizationContract; +use Spatie\SchemaOrg\Contracts\PersonContract; +use Spatie\SchemaOrg\Contracts\PropertyValueContract; +use Spatie\SchemaOrg\Contracts\ThingContract; /** * A body of structured information describing some topic(s) of interest. @@ -17,7 +25,7 @@ class Study extends BaseType * in that HTML 5 provides a special mechanism for indicating authorship via * the rel tag. That is equivalent to this and may be used interchangeably. * - * @param \Spatie\SchemaOrg\Contracts\OrganizationContract|\Spatie\SchemaOrg\Contracts\OrganizationContract[]|\Spatie\SchemaOrg\Contracts\PersonContract|\Spatie\SchemaOrg\Contracts\PersonContract[] $author + * @param OrganizationContract|OrganizationContract[]|PersonContract|PersonContract[] $author * @return static * * @see https://schema.org/author @@ -60,7 +68,7 @@ public function description($description) * strings or as URL (URI) links. See [background * notes](/docs/datamodel.html#identifierBg) for more details. * - * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[]|string|string[] $identifier + * @param PropertyValueContract|PropertyValueContract[]|string|string[] $identifier * @return static * * @see https://schema.org/identifier @@ -88,7 +96,7 @@ public function name($name) * functional genomics or earth science. Those domains can also have an ontology * reference. * - * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[]|string|string[] $studyDomain + * @param PropertyValueContract|PropertyValueContract[]|string|string[] $studyDomain * @return static */ public function studyDomain($studyDomain) @@ -100,7 +108,7 @@ public function studyDomain($studyDomain) * A subject of the study, i.e. one of the medical conditions, therapies, devices, * drugs, etc. investigated by the study. * - * @param \Spatie\SchemaOrg\Contracts\BioChemEntityContract|\Spatie\SchemaOrg\Contracts\MedicalEntityContract[] $studySubject + * @param BioChemEntityContract|MedicalEntityContract[] $studySubject * @return static */ public function studySubject($studySubject) @@ -111,7 +119,7 @@ public function studySubject($studySubject) /** * The subject matter of the content. * - * @param \Spatie\SchemaOrg\Contracts\ThingContract|\Spatie\SchemaOrg\Contracts\ThingContract[] $about + * @param ThingContract|ThingContract[] $about * @return static * * @see https://schema.org/about @@ -131,7 +139,7 @@ public function about($about) * such data to be provided using those properties, rather than using the generic * property/value mechanism. * - * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[] $additionalProperty + * @param PropertyValueContract|PropertyValueContract[] $additionalProperty * @return static * * @see https://schema.org/additionalProperty @@ -145,7 +153,7 @@ public function additionalProperty($additionalProperty) * A citation or reference to another creative work, such as another * publication, web page, scholarly article, etc. * - * @param \Spatie\SchemaOrg\Contracts\CreativeWorkContract|\Spatie\SchemaOrg\Contracts\CreativeWorkContract[]|string|string[] $citation + * @param CreativeWorkContract|CreativeWorkContract[]|string|string[] $citation * @return static * * @see https://schema.org/citation @@ -159,7 +167,7 @@ public function citation($citation) * The creator/author of this CreativeWork. This is the same as the Author * property for CreativeWork. * - * @param \Spatie\SchemaOrg\Contracts\OrganizationContract|\Spatie\SchemaOrg\Contracts\OrganizationContract[]|\Spatie\SchemaOrg\Contracts\PersonContract|\Spatie\SchemaOrg\Contracts\PersonContract[] $creator + * @param OrganizationContract|OrganizationContract[]|PersonContract|PersonContract[] $creator * @return static * * @see https://schema.org/creator @@ -214,7 +222,7 @@ public function startDate($startDate) * a keywords list are typically delimited by commas, or by repeating the * property. * - * @param \Spatie\SchemaOrg\Contracts\DefinedTermContract|\Spatie\SchemaOrg\Contracts\DefinedTermContract[]|string|string[] $keywords + * @param DefinedTermContract|DefinedTermContract[]|string|string[] $keywords * @return static * * @see https://schema.org/keywords @@ -228,7 +236,7 @@ public function keywords($keywords) * TA process performed as part of an experiment or wider study, i.e. intentionally * designed. These processes can have ontology URL attached to. * - * @param \Spatie\SchemaOrg\Contracts\PropertyValueContract|\Spatie\SchemaOrg\Contracts\PropertyValueContract[]|string|string[] $studyProcess + * @param PropertyValueContract|PropertyValueContract[]|string|string[] $studyProcess * @return static */ public function studyProcess($studyProcess) diff --git a/app/Models/Study.php b/app/Models/Study.php index e3af06571..f053f2ec4 100644 --- a/app/Models/Study.php +++ b/app/Models/Study.php @@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\MorphOne; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; use Laravel\Scout\Searchable; @@ -270,7 +271,7 @@ public function owner(): BelongsTo /** * Get all of the study's users including its owner. * - * @return \Illuminate\Support\Collection + * @return Collection */ public function allUsers() { @@ -305,7 +306,7 @@ public function molecules() /** * Remove the given user from the study. * - * @param \App\Models\User $user + * @param User $user * @return void */ public function removeUser($user) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 6ff96d88d..474ba212b 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,10 @@ namespace App\Providers; +use App\Services\FileIntegrityService; +use App\Services\FileSystemObjectService; +use App\Services\PathGeneratorService; +use App\Services\StorageSignedUrlService; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Event; @@ -42,10 +46,10 @@ class AppServiceProvider extends ServiceProvider public function register(): void { // Register filesystem services - $this->app->singleton(\App\Services\PathGeneratorService::class); - $this->app->singleton(\App\Services\StorageSignedUrlService::class); - $this->app->singleton(\App\Services\FileIntegrityService::class); - $this->app->bind(\App\Services\FileSystemObjectService::class); + $this->app->singleton(PathGeneratorService::class); + $this->app->singleton(StorageSignedUrlService::class); + $this->app->singleton(FileIntegrityService::class); + $this->app->bind(FileSystemObjectService::class); } /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index fbef8d473..465a89e10 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -6,8 +6,10 @@ use App\Events\StudyPublish; use App\Listeners\SendDraftProcessedNotification; use App\Listeners\StudyPublish as StudyPublishListener; +use App\Services\Socialite\NFDIAAI\Provider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; +use SocialiteProviders\Manager\SocialiteWasCalled; class EventServiceProvider extends ServiceProvider { @@ -43,9 +45,9 @@ public function boot(): void // Manually register event listeners as fallback Event::listen(DraftProcessed::class, SendDraftProcessedNotification::class); Event::listen(StudyPublish::class, StudyPublishListener::class); - Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) { + Event::listen(function (SocialiteWasCalled $event) { // Canonical slug for NFDI AAI provider is 'regapp' (matches IdP registered callback URI) - $event->extendSocialite('regapp', \App\Services\Socialite\NFDIAAI\Provider::class); + $event->extendSocialite('regapp', Provider::class); }); } } diff --git a/app/Services/FileIntegrityService.php b/app/Services/FileIntegrityService.php index 5b75e8dd8..e6c04542a 100644 --- a/app/Services/FileIntegrityService.php +++ b/app/Services/FileIntegrityService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Models\FileSystemObject; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; @@ -178,7 +179,7 @@ private function verifyChecksums(FileSystemObject $fileSystemObject, string $fil /** * Get files pending integrity verification. */ - public function getFilesPendingVerification(int $limit = 100): \Illuminate\Database\Eloquent\Collection + public function getFilesPendingVerification(int $limit = 100): Collection { return FileSystemObject::where('type', 'file') ->where('integrity_status', 'pending') @@ -191,7 +192,7 @@ public function getFilesPendingVerification(int $limit = 100): \Illuminate\Datab /** * Get files with failed integrity verification. */ - public function getFilesWithFailedIntegrity(int $limit = 100): \Illuminate\Database\Eloquent\Collection + public function getFilesWithFailedIntegrity(int $limit = 100): Collection { return FileSystemObject::where('type', 'file') ->where('integrity_status', 'failed') diff --git a/app/Services/FileSystemObjectService.php b/app/Services/FileSystemObjectService.php index 65e1ae83d..bedd2963f 100644 --- a/app/Services/FileSystemObjectService.php +++ b/app/Services/FileSystemObjectService.php @@ -7,6 +7,7 @@ use App\Models\FileSystemObject; use App\Models\Project; use App\Models\Study; +use Illuminate\Database\QueryException; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; @@ -28,7 +29,7 @@ public function __construct( /** * Create file system object for draft uploads. * - * @throws \Illuminate\Database\QueryException + * @throws QueryException */ public function createDraftFileSystemObject( Draft $draft, @@ -51,7 +52,7 @@ public function createDraftFileSystemObject( /** * Create file system object for project uploads. * - * @throws \Illuminate\Database\QueryException + * @throws QueryException */ public function createProjectFileSystemObject( Project $project, @@ -211,7 +212,7 @@ private function findOrCreateDirectory( $directory = FileSystemObject::create($creationDefaults); return $directory; - } catch (\Illuminate\Database\QueryException $e) { + } catch (QueryException $e) { // Handle unique constraint violation - another process created it if ($e->getCode() === '23000' || str_contains($e->getMessage(), 'Duplicate entry')) { // Fetch the directory that was created by the other process @@ -286,7 +287,7 @@ private function createFileObject( $fileObject = FileSystemObject::create($creationDefaults); return ['fileObject' => $fileObject, 'wasRecentlyCreated' => true]; - } catch (\Illuminate\Database\QueryException $e) { + } catch (QueryException $e) { // Handle unique constraint violation - another process created it if ($e->getCode() === '23000' || str_contains($e->getMessage(), 'Duplicate entry')) { // Fetch the file that was created by the other process diff --git a/bootstrap/app.php b/bootstrap/app.php index 2e90a86ce..6db7b45e4 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,16 +1,29 @@ withProviders([ - \SocialiteProviders\Manager\ServiceProvider::class, - \OwenIt\Auditing\AuditingServiceProvider::class, - \Lab404\Impersonate\ImpersonateServiceProvider::class, - \L5Swagger\L5SwaggerServiceProvider::class, + ServiceProvider::class, + AuditingServiceProvider::class, + ImpersonateServiceProvider::class, + L5SwaggerServiceProvider::class, ]) ->withRouting( web: __DIR__.'/../routes/web.php', @@ -28,13 +41,13 @@ 'support-bubble', ]); - $middleware->append(\Spatie\CookieConsent\CookieConsentMiddleware::class); + $middleware->append(CookieConsentMiddleware::class); $middleware->web([ - \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class, - \App\Http\Middleware\HandleInertiaRequests::class, - \App\Http\Middleware\XFrameOptions::class, - \Spatie\Csp\AddCspHeaders::class, + AuthenticateSession::class, + HandleInertiaRequests::class, + XFrameOptions::class, + AddCspHeaders::class, ]); // Disable API throttling in testing environment to allow test suite to run @@ -42,12 +55,12 @@ $middleware->throttleApi(); } - $middleware->replace(\Illuminate\Http\Middleware\TrustProxies::class, \App\Http\Middleware\TrustProxies::class); + $middleware->replace(TrustProxies::class, App\Http\Middleware\TrustProxies::class); $middleware->alias([ - 'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class, - 'role' => \Spatie\Permission\Middleware\RoleMiddleware::class, - 'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class, + 'permission' => PermissionMiddleware::class, + 'role' => RoleMiddleware::class, + 'role_or_permission' => RoleOrPermissionMiddleware::class, ]); }) ->withExceptions(function (Exceptions $exceptions) { diff --git a/bootstrap/providers.php b/bootstrap/providers.php index 3783965e1..d66cc53af 100644 --- a/bootstrap/providers.php +++ b/bootstrap/providers.php @@ -1,14 +1,25 @@ env('AUDITING_ENABLED', true), @@ -13,7 +19,7 @@ | */ - 'implementation' => OwenIt\Auditing\Models\Audit::class, + 'implementation' => Audit::class, /* |-------------------------------------------------------------------------- @@ -30,7 +36,7 @@ 'web', 'api', ], - 'resolver' => OwenIt\Auditing\Resolvers\UserResolver::class, + 'resolver' => UserResolver::class, ], /* @@ -42,9 +48,9 @@ | */ 'resolvers' => [ - 'ip_address' => OwenIt\Auditing\Resolvers\IpAddressResolver::class, - 'user_agent' => OwenIt\Auditing\Resolvers\UserAgentResolver::class, - 'url' => OwenIt\Auditing\Resolvers\UrlResolver::class, + 'ip_address' => IpAddressResolver::class, + 'user_agent' => UserAgentResolver::class, + 'url' => UrlResolver::class, ], /* diff --git a/config/backup.php b/config/backup.php index 2bcc6148f..a8c617038 100644 --- a/config/backup.php +++ b/config/backup.php @@ -1,5 +1,16 @@ [ @@ -151,19 +162,19 @@ 'notifications' => [ 'notifications' => [ - \Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'], - \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => ['mail'], - \Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => ['mail'], - \Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => ['mail'], - \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => ['mail'], - \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => ['mail'], + BackupHasFailedNotification::class => ['mail'], + UnhealthyBackupWasFoundNotification::class => ['mail'], + CleanupHasFailedNotification::class => ['mail'], + BackupWasSuccessfulNotification::class => ['mail'], + HealthyBackupWasFoundNotification::class => ['mail'], + CleanupWasSuccessfulNotification::class => ['mail'], ], /* * Here you can specify the notifiable to which the notifications should be sent. The default * notifiable will use the variables specified in this config file. */ - 'notifiable' => \Spatie\Backup\Notifications\Notifiable::class, + 'notifiable' => Notifiable::class, 'mail' => [ 'to' => env('MAIL_FROM_ADDRESS', 'info.nmrxiv@uni-jena.de'), @@ -213,8 +224,8 @@ 'name' => env('APP_NAME', 'laravel-backup'), 'disks' => ['local'], 'health_checks' => [ - \Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumAgeInDays::class => 1, - \Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumStorageInMegabytes::class => 5000, + MaximumAgeInDays::class => 1, + MaximumStorageInMegabytes::class => 5000, ], ], @@ -240,7 +251,7 @@ * No matter how you configure it the default strategy will never * delete the newest backup. */ - 'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class, + 'strategy' => DefaultStrategy::class, 'default_strategy' => [ diff --git a/config/csp.php b/config/csp.php index 695928300..624bc267d 100644 --- a/config/csp.php +++ b/config/csp.php @@ -1,5 +1,9 @@ [ // Enforcement mode - now using secure CSP policy - App\Support\Csp\Policies\NmrxivPolicy::class, + NmrxivPolicy::class, ], /** @@ -21,22 +25,22 @@ 'directives' => [ // Additional connect-src domains (configurable via env) ...(env('CSP_ADDITIONAL_CONNECT_SRC') ? [ - [Spatie\Csp\Directive::CONNECT, array_filter(explode(',', env('CSP_ADDITIONAL_CONNECT_SRC')))], + [Directive::CONNECT, array_filter(explode(',', env('CSP_ADDITIONAL_CONNECT_SRC')))], ] : []), // Additional img-src domains (configurable via env) ...(env('CSP_ADDITIONAL_IMG_SRC') ? [ - [Spatie\Csp\Directive::IMG, array_filter(explode(',', env('CSP_ADDITIONAL_IMG_SRC')))], + [Directive::IMG, array_filter(explode(',', env('CSP_ADDITIONAL_IMG_SRC')))], ] : []), // Additional script-src domains (configurable via env) ...(env('CSP_ADDITIONAL_SCRIPT_SRC') ? [ - [Spatie\Csp\Directive::SCRIPT, array_filter(explode(',', env('CSP_ADDITIONAL_SCRIPT_SRC')))], + [Directive::SCRIPT, array_filter(explode(',', env('CSP_ADDITIONAL_SCRIPT_SRC')))], ] : []), // Additional style-src domains (configurable via env) ...(env('CSP_ADDITIONAL_STYLE_SRC') ? [ - [Spatie\Csp\Directive::STYLE, array_filter(explode(',', env('CSP_ADDITIONAL_STYLE_SRC')))], + [Directive::STYLE, array_filter(explode(',', env('CSP_ADDITIONAL_STYLE_SRC')))], ] : []), ], @@ -74,7 +78,7 @@ /* * The class responsible for generating the nonces used in inline tags and headers. */ - 'nonce_generator' => Spatie\Csp\Nonce\RandomString::class, + 'nonce_generator' => RandomString::class, /* * Set false to disable automatic nonce generation and handling. diff --git a/config/l5-swagger.php b/config/l5-swagger.php index 31ed18a3f..779030533 100644 --- a/config/l5-swagger.php +++ b/config/l5-swagger.php @@ -1,5 +1,8 @@ 'default', 'documentations' => [ @@ -106,14 +109,14 @@ /** * analyser: defaults to \OpenApi\StaticAnalyser . * - * @see \OpenApi\scan + * @see scan */ 'analyser' => null, /** * analysis: defaults to a new \OpenApi\Analysis . * - * @see \OpenApi\scan + * @see scan */ 'analysis' => null, @@ -121,7 +124,7 @@ * Custom query path processors classes. * * @link https://github.com/zircote/swagger-php/tree/master/Examples/schema-query-parameter-processor - * @see \OpenApi\scan + * @see scan */ 'processors' => [ // new \App\SwaggerProcessors\SchemaQueryParameter(), @@ -130,7 +133,7 @@ /** * pattern: string $pattern File pattern(s) to scan (default: *.php) . * - * @see \OpenApi\scan + * @see scan */ 'pattern' => null, @@ -145,7 +148,7 @@ * Allows to generate specs either for OpenAPI 3.0.0 or OpenAPI 3.1.0. * By default the spec will be in version 3.0.0 */ - 'open_api_spec_version' => env('L5_SWAGGER_OPEN_API_SPEC_VERSION', \L5Swagger\Generator::OPEN_API_DEFAULT_SPEC_VERSION), + 'open_api_spec_version' => env('L5_SWAGGER_OPEN_API_SPEC_VERSION', Generator::OPEN_API_DEFAULT_SPEC_VERSION), ], /* diff --git a/config/markable.php b/config/markable.php index 4ff4333b3..c5722db6c 100644 --- a/config/markable.php +++ b/config/markable.php @@ -1,5 +1,7 @@ App\Models\User::class, + 'user_model' => User::class, /* |-------------------------------------------------------------------------- diff --git a/config/permission.php b/config/permission.php index c306a8d50..106f3159f 100644 --- a/config/permission.php +++ b/config/permission.php @@ -1,5 +1,8 @@ [ @@ -13,7 +16,7 @@ * `Spatie\Permission\Contracts\Permission` contract. */ - 'permission' => Spatie\Permission\Models\Permission::class, + 'permission' => Permission::class, /* * When using the "HasRoles" trait from this package, we need to know which @@ -24,7 +27,7 @@ * `Spatie\Permission\Contracts\Role` contract. */ - 'role' => Spatie\Permission\Models\Role::class, + 'role' => Role::class, ], @@ -113,7 +116,7 @@ * When permissions or roles are updated the cache is flushed automatically. */ - 'expiration_time' => \DateInterval::createFromDateString('24 hours'), + 'expiration_time' => DateInterval::createFromDateString('24 hours'), /* * The cache key used to store all permissions. diff --git a/config/queue.php b/config/queue.php index 53eb2656e..e96beaf42 100644 --- a/config/queue.php +++ b/config/queue.php @@ -1,5 +1,8 @@ [ @@ -7,7 +10,7 @@ 'driver' => 'rabbitmq', 'queue' => env('RABBITMQ_QUEUE', 'default'), - 'connection' => PhpAmqpLib\Connection\AMQPLazyConnection::class, + 'connection' => AMQPLazyConnection::class, 'hosts' => [ [ @@ -28,7 +31,7 @@ 'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null), ], 'queue' => [ - 'job' => VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob::class, + 'job' => RabbitMQJob::class, ], ], diff --git a/config/sanctum.php b/config/sanctum.php index 764a82fac..b6607039b 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -1,5 +1,8 @@ [ - 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, - 'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class, - 'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class, + 'authenticate_session' => AuthenticateSession::class, + 'encrypt_cookies' => EncryptCookies::class, + 'validate_csrf_token' => ValidateCsrfToken::class, ], ]; diff --git a/config/tags.php b/config/tags.php index 0b965495d..fbae79b70 100644 --- a/config/tags.php +++ b/config/tags.php @@ -1,5 +1,7 @@ Spatie\Tags\Tag::class, + 'tag_model' => Tag::class, ]; diff --git a/database/factories/AnnouncementFactory.php b/database/factories/AnnouncementFactory.php index ae3f7d0b4..4c04223e9 100644 --- a/database/factories/AnnouncementFactory.php +++ b/database/factories/AnnouncementFactory.php @@ -2,13 +2,14 @@ namespace Database\Factories; +use App\Models\Announcement; use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Carbon; use Illuminate\Support\Str; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Announcement> + * @extends Factory */ class AnnouncementFactory extends Factory { diff --git a/database/factories/AuthorFactory.php b/database/factories/AuthorFactory.php index cd7caf98d..6d4ea3121 100644 --- a/database/factories/AuthorFactory.php +++ b/database/factories/AuthorFactory.php @@ -2,10 +2,11 @@ namespace Database\Factories; +use App\Models\Author; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Author> + * @extends Factory */ class AuthorFactory extends Factory { diff --git a/database/factories/CitationFactory.php b/database/factories/CitationFactory.php index bd0359bc5..3d075b608 100644 --- a/database/factories/CitationFactory.php +++ b/database/factories/CitationFactory.php @@ -2,10 +2,11 @@ namespace Database\Factories; +use App\Models\Citation; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Citation> + * @extends Factory */ class CitationFactory extends Factory { diff --git a/database/factories/DraftFactory.php b/database/factories/DraftFactory.php index 3d1b3c7d1..7361f9867 100644 --- a/database/factories/DraftFactory.php +++ b/database/factories/DraftFactory.php @@ -2,13 +2,14 @@ namespace Database\Factories; +use App\Models\Draft; use App\Models\Team; use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Draft> + * @extends Factory */ class DraftFactory extends Factory { diff --git a/database/factories/FileSystemObjectFactory.php b/database/factories/FileSystemObjectFactory.php index 38216f211..56e5e4d1f 100644 --- a/database/factories/FileSystemObjectFactory.php +++ b/database/factories/FileSystemObjectFactory.php @@ -3,13 +3,14 @@ namespace Database\Factories; use App\Models\Draft; +use App\Models\FileSystemObject; use App\Models\Project; use App\Models\Study; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\FileSystemObject> + * @extends Factory */ class FileSystemObjectFactory extends Factory { diff --git a/database/factories/LicenseFactory.php b/database/factories/LicenseFactory.php index 6b0545ac1..afcdc09e8 100644 --- a/database/factories/LicenseFactory.php +++ b/database/factories/LicenseFactory.php @@ -7,7 +7,7 @@ use Illuminate\Support\Str; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\License> + * @extends Factory */ class LicenseFactory extends Factory { diff --git a/database/factories/NMRiumFactory.php b/database/factories/NMRiumFactory.php index 1f2fd53b1..c2237629c 100644 --- a/database/factories/NMRiumFactory.php +++ b/database/factories/NMRiumFactory.php @@ -2,10 +2,13 @@ namespace Database\Factories; +use App\Models\Dataset; +use App\Models\Model; +use App\Models\Study; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model> + * @extends Factory */ class NMRiumFactory extends Factory { @@ -17,7 +20,7 @@ public function definition(): array return [ 'nmrium_info' => '{}', 'nmriumable_id' => 1, - 'nmriumable_type' => \App\Models\Dataset::class, + 'nmriumable_type' => Dataset::class, ]; } @@ -27,8 +30,8 @@ public function definition(): array public function forDataset($dataset = null): static { return $this->state(fn (array $attributes) => [ - 'nmriumable_id' => $dataset?->id ?? \App\Models\Dataset::factory(), - 'nmriumable_type' => \App\Models\Dataset::class, + 'nmriumable_id' => $dataset?->id ?? Dataset::factory(), + 'nmriumable_type' => Dataset::class, ]); } @@ -38,8 +41,8 @@ public function forDataset($dataset = null): static public function forStudy($study = null): static { return $this->state(fn (array $attributes) => [ - 'nmriumable_id' => $study?->id ?? \App\Models\Study::factory(), - 'nmriumable_type' => \App\Models\Study::class, + 'nmriumable_id' => $study?->id ?? Study::factory(), + 'nmriumable_type' => Study::class, ]); } } diff --git a/database/factories/ProjectInvitationFactory.php b/database/factories/ProjectInvitationFactory.php index fac1d05dd..5fc75005d 100644 --- a/database/factories/ProjectInvitationFactory.php +++ b/database/factories/ProjectInvitationFactory.php @@ -3,11 +3,12 @@ namespace Database\Factories; use App\Models\Project; +use App\Models\ProjectInvitation; use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ProjectInvitation> + * @extends Factory */ class ProjectInvitationFactory extends Factory { diff --git a/database/factories/TeamInvitationFactory.php b/database/factories/TeamInvitationFactory.php index b76b33434..1991fb438 100644 --- a/database/factories/TeamInvitationFactory.php +++ b/database/factories/TeamInvitationFactory.php @@ -3,11 +3,12 @@ namespace Database\Factories; use App\Models\Team; +use App\Models\TeamInvitation; use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TeamInvitation> + * @extends Factory */ class TeamInvitationFactory extends Factory { diff --git a/database/factories/TickerFactory.php b/database/factories/TickerFactory.php index 3676b451d..77b816caf 100644 --- a/database/factories/TickerFactory.php +++ b/database/factories/TickerFactory.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Ticker> + * @extends Factory */ class TickerFactory extends Factory { diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 66c62b21a..04cc01776 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -30,7 +30,7 @@ public function definition(): array /** * Indicate that the model's email address should be unverified. * - * @return \Illuminate\Database\Eloquent\Factories\Factory + * @return Factory */ public function unverified() { diff --git a/database/factories/ValidationFactory.php b/database/factories/ValidationFactory.php index aeefb801a..a2175b801 100644 --- a/database/factories/ValidationFactory.php +++ b/database/factories/ValidationFactory.php @@ -2,10 +2,11 @@ namespace Database\Factories; +use App\Models\Validation; use Illuminate\Database\Eloquent\Factories\Factory; /** - * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Validation> + * @extends Factory */ class ValidationFactory extends Factory { diff --git a/database/migrations/2021_08_26_154527_create_permission_tables.php b/database/migrations/2021_08_26_154527_create_permission_tables.php index 574f58927..05287893b 100644 --- a/database/migrations/2021_08_26_154527_create_permission_tables.php +++ b/database/migrations/2021_08_26_154527_create_permission_tables.php @@ -15,7 +15,7 @@ public function up(): void $columnNames = config('permission.column_names'); if (empty($tableNames)) { - throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.'); + throw new Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.'); } Schema::create($tableNames['permissions'], function (Blueprint $table) { @@ -98,7 +98,7 @@ public function down(): void $tableNames = config('permission.table_names'); if (empty($tableNames)) { - throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + throw new Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); } Schema::drop($tableNames['role_has_permissions']); diff --git a/database/migrations/2023_08_25_111326_update_nmrium_table.php b/database/migrations/2023_08_25_111326_update_nmrium_table.php index 045c5cb60..e10cfb156 100644 --- a/database/migrations/2023_08_25_111326_update_nmrium_table.php +++ b/database/migrations/2023_08_25_111326_update_nmrium_table.php @@ -1,5 +1,6 @@ renameColumn('dataset_id', 'nmriumable_id'); - $table->string('nmriumable_type')->default(\App\Models\Dataset::class); + $table->string('nmriumable_type')->default(Dataset::class); }); Schema::table('studies', function (Blueprint $table) { diff --git a/database/seeders/RolesAndPermissionsSeeder.php b/database/seeders/RolesAndPermissionsSeeder.php index 18a5680f1..76e9798f7 100644 --- a/database/seeders/RolesAndPermissionsSeeder.php +++ b/database/seeders/RolesAndPermissionsSeeder.php @@ -5,6 +5,7 @@ use Illuminate\Database\Seeder; use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; +use Spatie\Permission\PermissionRegistrar; class RolesAndPermissionsSeeder extends Seeder { @@ -14,7 +15,7 @@ class RolesAndPermissionsSeeder extends Seeder public function run(): void { // Reset cached roles and permissions - app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions(); + app()[PermissionRegistrar::class]->forgetCachedPermissions(); // create permissions Permission::create(['name' => 'view studies']); diff --git a/routes/web.php b/routes/web.php index 26a765e45..3ddeb6ddb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,9 +22,11 @@ use App\Http\Controllers\ProjectController; use App\Http\Controllers\ProjectInvitationController; use App\Http\Controllers\ProjectMemberController; +use App\Http\Controllers\RorController; use App\Http\Controllers\StudyController; use App\Http\Controllers\StudyInvitationController; use App\Http\Controllers\StudyMemberController; +use App\Http\Controllers\SupportBubbleController; use App\Http\Controllers\TeamController; use App\Http\Controllers\UploadController; use App\Models\Dataset; @@ -93,7 +95,7 @@ })->name('predict'); // Custom support bubble route with rate limiting and enhanced security -Route::post('support-bubble', [\App\Http\Controllers\SupportBubbleController::class, 'submit']) +Route::post('support-bubble', [SupportBubbleController::class, 'submit']) ->middleware(['throttle:support-bubble']) ->name('supportBubble.submit'); @@ -130,7 +132,7 @@ }); // ROR API - publicly accessible with rate limiting -Route::get('ror/search', [\App\Http\Controllers\RorController::class, 'search']) +Route::get('ror/search', [RorController::class, 'search']) ->middleware('throttle:60,1') ->name('ror.search'); diff --git a/tests/API/ELNControllerTest.php b/tests/API/ELNControllerTest.php index c1a839cbc..960e39a99 100644 --- a/tests/API/ELNControllerTest.php +++ b/tests/API/ELNControllerTest.php @@ -450,7 +450,7 @@ public function test_eln_upload_with_future_release_date() $draft = Draft::where('external_id', 'CHEM-FUTURE-001')->first(); // Database stores as date, compare date strings - $this->assertEquals($futureDate, $draft->release_date instanceof \Carbon\Carbon ? $draft->release_date->toDateString() : $draft->release_date); + $this->assertEquals($futureDate, $draft->release_date instanceof Carbon ? $draft->release_date->toDateString() : $draft->release_date); } /** diff --git a/tests/Feature/CspTest.php b/tests/Feature/CspTest.php index ab2d34c81..420c9f576 100644 --- a/tests/Feature/CspTest.php +++ b/tests/Feature/CspTest.php @@ -4,6 +4,9 @@ use App\Support\Csp\Policies\NmrxivPolicy; use Illuminate\Foundation\Testing\WithoutMiddleware; +use Spatie\Csp\AddCspHeaders; +use Spatie\Csp\Policy; +use Spatie\Csp\Preset; use Tests\TestCase; class CspTest extends TestCase @@ -16,25 +19,25 @@ public function test_csp_policy_configuration(): void // Test that the policy class exists and implements the correct interface $this->assertInstanceOf(NmrxivPolicy::class, $nmrxivPolicy); - $this->assertInstanceOf(\Spatie\Csp\Preset::class, $nmrxivPolicy); + $this->assertInstanceOf(Preset::class, $nmrxivPolicy); // Test that the configure method exists and can be called - $policy = new \Spatie\Csp\Policy; + $policy = new Policy; // Should not throw any exceptions $nmrxivPolicy->configure($policy); // Test that the policy object exists after configuration - $this->assertInstanceOf(\Spatie\Csp\Policy::class, $policy); + $this->assertInstanceOf(Policy::class, $policy); } public function test_csp_middleware_is_registered(): void { // Test that the CSP middleware class exists - $this->assertTrue(class_exists(\Spatie\Csp\AddCspHeaders::class)); + $this->assertTrue(class_exists(AddCspHeaders::class)); // Test that the policy class exists and is properly configured - $this->assertTrue(class_exists(\App\Support\Csp\Policies\NmrxivPolicy::class)); + $this->assertTrue(class_exists(NmrxivPolicy::class)); } public function test_csp_uses_unsafe_inline_for_compatibility(): void @@ -43,7 +46,7 @@ public function test_csp_uses_unsafe_inline_for_compatibility(): void app()->detectEnvironment(fn () => 'production'); config(['app.env' => 'production']); - $policy = new \Spatie\Csp\Policy; + $policy = new Policy; (new NmrxivPolicy)->configure($policy); $policyString = $policy->getContents(); @@ -62,7 +65,7 @@ public function test_csp_unsafe_inline_in_local(): void app()->detectEnvironment(fn () => 'local'); config(['app.env' => 'local']); - $policy = new \Spatie\Csp\Policy; + $policy = new Policy; (new NmrxivPolicy)->configure($policy); $policyString = $policy->getContents(); diff --git a/tests/Feature/ExternalServices/ELN/ChemotionMetadataServiceTest.php b/tests/Feature/ExternalServices/ELN/ChemotionMetadataServiceTest.php index 8a301d6d7..97d60f578 100644 --- a/tests/Feature/ExternalServices/ELN/ChemotionMetadataServiceTest.php +++ b/tests/Feature/ExternalServices/ELN/ChemotionMetadataServiceTest.php @@ -5,6 +5,7 @@ use App\Models\Draft; use App\Models\FileSystemObject; use App\Services\ELN\ChemotionMetadataService; +use App\Services\ELN\ELNMetadataExtractorInterface; use App\Services\FileIntegrityService; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Log; @@ -29,7 +30,7 @@ protected function setUp(): void public function test_service_implements_interface(): void { - $this->assertInstanceOf(\App\Services\ELN\ELNMetadataExtractorInterface::class, $this->service); + $this->assertInstanceOf(ELNMetadataExtractorInterface::class, $this->service); } public function test_get_eln_type_returns_chemotion(): void diff --git a/tests/Feature/ExternalServices/ELN/ProcessDraftELNSubmissionProxyTest.php b/tests/Feature/ExternalServices/ELN/ProcessDraftELNSubmissionProxyTest.php index b23c03c2e..108d4a787 100644 --- a/tests/Feature/ExternalServices/ELN/ProcessDraftELNSubmissionProxyTest.php +++ b/tests/Feature/ExternalServices/ELN/ProcessDraftELNSubmissionProxyTest.php @@ -2,8 +2,10 @@ namespace Tests\Feature\ExternalServices\ELN; +use App\Actions\Draft\DraftProcessingLogger; use App\Jobs\ProcessDraftELNSubmission; use App\Models\Draft; +use App\Services\PathGeneratorService; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Http; @@ -40,12 +42,12 @@ public function test_http_client_uses_proxy_when_configured(): void $method->setAccessible(true); // Mock the PathGeneratorService - $pathGenerator = $this->createMock(\App\Services\PathGeneratorService::class); + $pathGenerator = $this->createMock(PathGeneratorService::class); $pathGenerator->method('generateDraftFilePath') ->willReturn('test/path/file.txt'); // Mock the DraftProcessingLogger (actual class lives under App\Actions\Draft) - $logger = $this->createMock(\App\Actions\Draft\DraftProcessingLogger::class); + $logger = $this->createMock(DraftProcessingLogger::class); try { // This will fail because we're not actually extracting a real zip, @@ -88,12 +90,12 @@ public function test_http_client_works_without_proxy_configuration(): void $method->setAccessible(true); // Mock the PathGeneratorService - $pathGenerator = $this->createMock(\App\Services\PathGeneratorService::class); + $pathGenerator = $this->createMock(PathGeneratorService::class); $pathGenerator->method('generateDraftFilePath') ->willReturn('test/path/file.txt'); // Mock the DraftProcessingLogger (actual class lives under App\Actions\Draft) - $logger = $this->createMock(\App\Actions\Draft\DraftProcessingLogger::class); + $logger = $this->createMock(DraftProcessingLogger::class); try { // This will fail because we're not actually extracting a real zip, diff --git a/tests/Feature/ExternalServices/NFDIAAIProviderTest.php b/tests/Feature/ExternalServices/NFDIAAIProviderTest.php index 840e2cce1..9964c6160 100644 --- a/tests/Feature/ExternalServices/NFDIAAIProviderTest.php +++ b/tests/Feature/ExternalServices/NFDIAAIProviderTest.php @@ -2,9 +2,14 @@ namespace Tests\Feature\ExternalServices; +use App\Services\Socialite\NFDIAAI\Provider; +use GuzzleHttp\Client; +use GuzzleHttp\RequestOptions; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use Mockery; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; use Tests\TestCase; class NFDIAAIProviderTest extends TestCase @@ -32,7 +37,7 @@ public function test_redirect_builds_authorization_url(): void public function test_provider_get_auth_url(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), config('services.regapp.client_id', 'test-client'), config('services.regapp.client_secret', 'test-secret'), @@ -52,7 +57,7 @@ public function test_provider_get_auth_url(): void public function test_provider_get_token_url(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), config('services.regapp.client_id', 'test-client'), config('services.regapp.client_secret', 'test-secret'), @@ -70,7 +75,7 @@ public function test_provider_get_token_url(): void public function test_provider_map_user_to_object_with_full_data(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), 'test-client', 'test-secret', @@ -100,7 +105,7 @@ public function test_provider_map_user_to_object_with_full_data(): void public function test_provider_map_user_to_object_with_fallback_fields(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), 'test-client', 'test-secret', @@ -129,7 +134,7 @@ public function test_provider_map_user_to_object_with_fallback_fields(): void public function test_provider_map_user_to_object_with_minimal_data(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), 'test-client', 'test-secret', @@ -155,24 +160,24 @@ public function test_provider_map_user_to_object_with_minimal_data(): void public function test_provider_get_user_by_token(): void { - $provider = Mockery::mock(\App\Services\Socialite\NFDIAAI\Provider::class) + $provider = Mockery::mock(Provider::class) ->makePartial() ->shouldAllowMockingProtectedMethods(); - $mockBody = Mockery::mock(\Psr\Http\Message\StreamInterface::class); + $mockBody = Mockery::mock(StreamInterface::class); $mockBody->shouldReceive('__toString') ->once() ->andReturn('{"sub":"test-user-id","email":"test@example.com","name":"Test User"}'); - $mockResponse = Mockery::mock(\Psr\Http\Message\ResponseInterface::class); + $mockResponse = Mockery::mock(ResponseInterface::class); $mockResponse->shouldReceive('getBody')->andReturn($mockBody); - $mockClient = Mockery::mock(\GuzzleHttp\Client::class); + $mockClient = Mockery::mock(Client::class); $mockClient->shouldReceive('get') ->with('https://regapp.nfdi-aai.de/oidc/realms/nfdi/protocol/openid-connect/userinfo', Mockery::on(function ($arg) { - return isset($arg[\GuzzleHttp\RequestOptions::HEADERS]['Authorization']) && - $arg[\GuzzleHttp\RequestOptions::HEADERS]['Authorization'] === 'Bearer test-token' && - $arg[\GuzzleHttp\RequestOptions::HEADERS]['Accept'] === 'application/json'; + return isset($arg[RequestOptions::HEADERS]['Authorization']) && + $arg[RequestOptions::HEADERS]['Authorization'] === 'Bearer test-token' && + $arg[RequestOptions::HEADERS]['Accept'] === 'application/json'; })) ->once() ->andReturn($mockResponse); @@ -193,7 +198,7 @@ public function test_provider_get_user_by_token(): void public function test_provider_map_user_handles_null_values(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), 'test-client', 'test-secret', @@ -217,7 +222,7 @@ public function test_provider_map_user_handles_null_values(): void public function test_provider_map_user_trims_name_from_parts(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), 'test-client', 'test-secret', @@ -242,7 +247,7 @@ public function test_provider_map_user_trims_name_from_parts(): void public function test_provider_map_user_with_only_given_name(): void { - $provider = new \App\Services\Socialite\NFDIAAI\Provider( + $provider = new Provider( request(), 'test-client', 'test-secret', diff --git a/tests/Feature/FileSystemTest.php b/tests/Feature/FileSystemTest.php index 4f3754937..817528226 100644 --- a/tests/Feature/FileSystemTest.php +++ b/tests/Feature/FileSystemTest.php @@ -2,12 +2,18 @@ namespace Tests\Feature; +use App\Http\Controllers\FileSystemController; use App\Models\Draft; use App\Models\FileSystemObject; use App\Models\Project; use App\Models\Study; use App\Models\Team; use App\Models\User; +use App\Services\FileIntegrityService; +use App\Services\FileSystemObjectService; +use App\Services\PathGeneratorService; +use App\Services\StorageSignedUrlService; +use Aws\S3\S3Client; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; @@ -303,7 +309,7 @@ public function test_is_bruker_identifies_bruker_folder(): void $directory->load('children'); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isBruker($directory); $this->assertTrue($result); @@ -323,7 +329,7 @@ public function test_is_bruker_returns_false_for_non_bruker_folder(): void $directory->load('children'); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isBruker($directory); $this->assertFalse($result); @@ -361,7 +367,7 @@ public function test_is_varian_identifies_varian_folder(): void $directory->load('children'); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isVarian($directory); $this->assertTrue($result); @@ -374,7 +380,7 @@ public function test_is_jcamp_dx_identifies_jdx_file(): void 'name' => 'spectrum.jdx', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isJcampDX($file); $this->assertTrue($result); @@ -387,7 +393,7 @@ public function test_is_jcamp_dx_identifies_dx_file(): void 'name' => 'spectrum.dx', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isJcampDX($file); $this->assertTrue($result); @@ -400,7 +406,7 @@ public function test_is_jcamp_dx_identifies_jcamp_file(): void 'name' => 'spectrum.jcamp', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isJcampDX($file); $this->assertTrue($result); @@ -413,7 +419,7 @@ public function test_is_nmredata_identifies_sdf_file(): void 'name' => 'molecule.sdf', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isNMReData($file); $this->assertTrue($result); @@ -426,7 +432,7 @@ public function test_is_mol_data_identifies_mol_file(): void 'name' => 'molecule.mol', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isMolData($file); $this->assertTrue($result); @@ -439,7 +445,7 @@ public function test_is_joel_identifies_jdf_file(): void 'name' => 'spectrum.jdf', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isJOEL($file); $this->assertTrue($result); @@ -452,7 +458,7 @@ public function test_save_instrument_type_updates_folder(): void 'instrument_type' => null, ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->saveInstrumentType($folder, 'bruker'); $folder->refresh(); @@ -466,7 +472,7 @@ public function test_save_model_type_updates_folder(): void 'model_type' => null, ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->saveModelType($folder, 'study'); $folder->refresh(); @@ -481,7 +487,7 @@ public function test_save_model_type_with_external_url(): void 'external_url' => null, ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->saveModelType($folder, 'analysis', 'https://example.com/analysis/123'); $folder->refresh(); @@ -561,7 +567,7 @@ public function test_process_folder_with_non_chemotion_draft(): void $this->draft->eln = null; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder($parentFolder->children); $brukerFolder->refresh(); @@ -600,7 +606,7 @@ public function test_process_folder_with_chemotion_draft(): void $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$brukerFolder]), $this->draft, false, null); $brukerFolder->refresh(); @@ -648,7 +654,7 @@ public function test_process_folder_with_varian_files(): void $varianFolder->load('children'); $parentFolder->load('children'); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder($parentFolder->children); $varianFolder->refresh(); @@ -672,7 +678,7 @@ public function test_process_folder_with_joel_file(): void 'name' => 'spectrum.jdf', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$joelFile])); $joelFile->refresh(); @@ -696,7 +702,7 @@ public function test_process_folder_with_jcamp_file(): void 'name' => 'spectrum.jdx', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$jcampFile])); $jcampFile->refresh(); @@ -722,7 +728,7 @@ public function test_process_folder_with_nmredata_file(): void 'study_id' => $this->study->id, ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$nmredataFile])); $nmredataFile->refresh(); @@ -739,7 +745,7 @@ public function test_process_folder_with_mol_file(): void 'name' => 'molecule.mol', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$molFile])); $molFile->refresh(); @@ -761,7 +767,7 @@ public function test_process_folder_skips_already_typed_folders(): void $folder->load('children'); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$folder])); $folder->refresh(); @@ -804,7 +810,7 @@ public function test_process_folder_recursive_processing(): void $rootFolder->load('children.children'); $subFolder->load('children'); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder($rootFolder->children); $subFolder->refresh(); @@ -821,7 +827,7 @@ public function test_save_annotations_detected_with_study(): void $this->study->has_nmredata = false; $this->study->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->saveAnnotationsDetected($folder); $this->study->refresh(); @@ -835,7 +841,7 @@ public function test_save_annotations_detected_without_study(): void 'study_id' => null, ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->saveAnnotationsDetected($folder); // Should not throw exception @@ -844,7 +850,7 @@ public function test_save_annotations_detected_without_study(): void public function test_save_annotations_detected_with_null_folder(): void { - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->saveAnnotationsDetected(null); // Should handle null gracefully @@ -854,11 +860,11 @@ public function test_save_annotations_detected_with_null_folder(): void public function test_delete_fso_with_actual_exception(): void { // Create a mock service that throws exception - $mockService = \Mockery::mock(\App\Services\FileSystemObjectService::class); + $mockService = \Mockery::mock(FileSystemObjectService::class); $mockService->shouldReceive('deleteFileSystemObject') ->andThrow(new \Exception('Database error')); - $this->app->instance(\App\Services\FileSystemObjectService::class, $mockService); + $this->app->instance(FileSystemObjectService::class, $mockService); $fso = FileSystemObject::factory()->file()->create([ 'draft_id' => $this->draft->id, @@ -892,7 +898,7 @@ public function log($draft, $level, $message) 'draft_id' => $this->draft->id, ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$folder]), $this->draft, true, $mockLogger); // Should process without errors @@ -917,7 +923,7 @@ public function test_process_folder_with_chemotion_nmredata_file(): void $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$nmredataFile]), $this->draft, false, null); $nmredataFile->refresh(); @@ -934,7 +940,7 @@ public function test_process_folder_with_chemotion_mol_file(): void $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$molFile]), $this->draft, false, null); $molFile->refresh(); @@ -951,7 +957,7 @@ public function test_process_folder_with_chemotion_joel_file(): void $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$joelFile]), $this->draft, false, null); $joelFile->refresh(); @@ -968,7 +974,7 @@ public function test_process_folder_with_chemotion_jcamp_file(): void $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$jcampFile]), $this->draft, false, null); $jcampFile->refresh(); @@ -1012,7 +1018,7 @@ public function test_process_folder_with_chemotion_recursive_non_instrument_fold $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$parentFolder]), $this->draft, false, null); $childFolder->refresh(); @@ -1026,7 +1032,7 @@ public function test_is_mol_data_returns_false_for_non_mol_file(): void 'name' => 'test.txt', ]); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $result = $controller->isMolData($file); $this->assertFalse($result); @@ -1075,7 +1081,7 @@ public function test_process_folder_with_chemotion_varian_recursive(): void $this->draft->eln = 'chemotion'; $this->draft->save(); - $controller = app(\App\Http\Controllers\FileSystemController::class); + $controller = app(FileSystemController::class); $controller->processFolder(collect([$parentFolder]), $this->draft, false, null); $varianFolder->refresh(); @@ -1091,7 +1097,7 @@ public function test_store_checksums_updates_file_with_md5(): void 'name' => 'test.txt', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $checksums = ['md5' => 'abc123def456']; $fileSize = 1024; @@ -1111,7 +1117,7 @@ public function test_store_checksums_updates_file_with_sha256(): void 'name' => 'test.txt', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $checksums = ['sha256' => 'abc123def456789']; $fileSize = 2048; @@ -1131,7 +1137,7 @@ public function test_store_checksums_prefers_sha256_over_md5(): void 'name' => 'test.txt', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $checksums = [ 'md5' => 'md5hash', 'sha256' => 'sha256hash', @@ -1156,7 +1162,7 @@ public function test_store_checksums_ignores_directories(): void $originalChecksum = $folder->checksum_md5; $originalAlgorithm = $folder->checksum_algorithm; - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $checksums = ['md5' => 'abc123']; $service->storeChecksums($folder, $checksums, 1024); @@ -1169,7 +1175,7 @@ public function test_store_checksums_ignores_directories(): void public function test_verify_file_integrity_succeeds_with_matching_checksum(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $fileContent = 'test file content'; $sha256 = hash('sha256', $fileContent); @@ -1184,9 +1190,9 @@ public function test_verify_file_integrity_succeeds_with_matching_checksum(): vo 'integrity_status' => 'pending', ]); - \Illuminate\Support\Facades\Storage::disk('local')->put('drafts/test.txt', $fileContent); + Storage::disk('local')->put('drafts/test.txt', $fileContent); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->verifyFileIntegrity($file); $this->assertTrue($result); @@ -1198,7 +1204,7 @@ public function test_verify_file_integrity_succeeds_with_matching_checksum(): vo public function test_verify_file_integrity_fails_with_mismatched_checksum(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $fileContent = 'test file content'; $wrongChecksum = 'wrongchecksumvalue'; @@ -1213,9 +1219,9 @@ public function test_verify_file_integrity_fails_with_mismatched_checksum(): voi 'integrity_status' => 'pending', ]); - \Illuminate\Support\Facades\Storage::disk('local')->put('drafts/test.txt', $fileContent); + Storage::disk('local')->put('drafts/test.txt', $fileContent); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->verifyFileIntegrity($file); $this->assertFalse($result); @@ -1227,7 +1233,7 @@ public function test_verify_file_integrity_fails_with_mismatched_checksum(): voi public function test_verify_file_integrity_fails_with_size_mismatch(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $fileContent = 'test file content'; $sha256 = hash('sha256', $fileContent); @@ -1242,9 +1248,9 @@ public function test_verify_file_integrity_fails_with_size_mismatch(): void 'integrity_status' => 'pending', ]); - \Illuminate\Support\Facades\Storage::disk('local')->put('drafts/test.txt', $fileContent); + Storage::disk('local')->put('drafts/test.txt', $fileContent); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->verifyFileIntegrity($file); $this->assertFalse($result); @@ -1255,7 +1261,7 @@ public function test_verify_file_integrity_fails_with_size_mismatch(): void public function test_verify_file_integrity_fails_when_file_not_in_storage(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $file = FileSystemObject::factory()->file()->create([ 'draft_id' => $this->draft->id, @@ -1266,7 +1272,7 @@ public function test_verify_file_integrity_fails_when_file_not_in_storage(): voi 'integrity_status' => 'pending', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->verifyFileIntegrity($file); $this->assertFalse($result); @@ -1286,7 +1292,7 @@ public function test_verify_file_integrity_fails_when_no_checksum(): void 'integrity_status' => 'pending', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->verifyFileIntegrity($file); $this->assertFalse($result); @@ -1305,13 +1311,13 @@ public function test_verify_file_integrity_throws_exception_for_directory(): voi 'name' => 'folder', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $service->verifyFileIntegrity($folder); } public function test_download_file_from_storage_returns_content(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $fileContent = 'test file content'; $file = FileSystemObject::factory()->file()->create([ @@ -1320,9 +1326,9 @@ public function test_download_file_from_storage_returns_content(): void 'path' => '/drafts/test.txt', ]); - \Illuminate\Support\Facades\Storage::disk('local')->put('drafts/test.txt', $fileContent); + Storage::disk('local')->put('drafts/test.txt', $fileContent); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->downloadFileFromStorage($file); $this->assertEquals($fileContent, $result); @@ -1330,7 +1336,7 @@ public function test_download_file_from_storage_returns_content(): void public function test_download_file_from_storage_returns_null_when_missing(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $file = FileSystemObject::factory()->file()->create([ 'draft_id' => $this->draft->id, @@ -1338,7 +1344,7 @@ public function test_download_file_from_storage_returns_null_when_missing(): voi 'path' => '/drafts/missing.txt', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $result = $service->downloadFileFromStorage($file); $this->assertNull($result); @@ -1370,7 +1376,7 @@ public function test_get_files_pending_verification(): void 'type' => 'file', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $pending = $service->getFilesPendingVerification(); $this->assertGreaterThanOrEqual(2, $pending->count()); @@ -1395,7 +1401,7 @@ public function test_get_files_with_failed_integrity(): void 'integrity_status' => 'verified', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $failed = $service->getFilesWithFailedIntegrity(); $this->assertCount(2, $failed); @@ -1406,7 +1412,7 @@ public function test_calculate_checksum_with_sha256(): void $content = 'test content'; $expected = hash('sha256', $content); - $result = \App\Services\FileIntegrityService::calculateChecksum($content, 'sha256'); + $result = FileIntegrityService::calculateChecksum($content, 'sha256'); $this->assertEquals($expected, $result); } @@ -1416,7 +1422,7 @@ public function test_calculate_checksum_with_md5(): void $content = 'test content'; $expected = md5($content); - $result = \App\Services\FileIntegrityService::calculateChecksum($content, 'md5'); + $result = FileIntegrityService::calculateChecksum($content, 'md5'); $this->assertEquals($expected, $result); } @@ -1426,7 +1432,7 @@ public function test_calculate_checksum_with_sha1(): void $content = 'test content'; $expected = sha1($content); - $result = \App\Services\FileIntegrityService::calculateChecksum($content, 'sha1'); + $result = FileIntegrityService::calculateChecksum($content, 'sha1'); $this->assertEquals($expected, $result); } @@ -1436,7 +1442,7 @@ public function test_calculate_checksum_defaults_to_sha256(): void $content = 'test content'; $expected = hash('sha256', $content); - $result = \App\Services\FileIntegrityService::calculateChecksum($content); + $result = FileIntegrityService::calculateChecksum($content); $this->assertEquals($expected, $result); } @@ -1459,7 +1465,7 @@ public function test_get_integrity_statistics(): void 'integrity_status' => 'failed', ]); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $stats = $service->getIntegrityStatistics(); $this->assertEquals(1, $stats['pending']); @@ -1470,7 +1476,7 @@ public function test_get_integrity_statistics(): void public function test_retry_failed_verifications(): void { - \Illuminate\Support\Facades\Storage::fake('local'); + Storage::fake('local'); $fileContent = 'test file content'; $correctChecksum = hash('sha256', $fileContent); @@ -1487,9 +1493,9 @@ public function test_retry_failed_verifications(): void 'verification_attempts' => 1, ]); - \Illuminate\Support\Facades\Storage::disk('local')->put('drafts/test.txt', $fileContent); + Storage::disk('local')->put('drafts/test.txt', $fileContent); - $service = app(\App\Services\FileIntegrityService::class); + $service = app(FileIntegrityService::class); $results = $service->retryFailedVerifications(); $this->assertEquals(1, $results['total']); @@ -1595,7 +1601,7 @@ public function test_file_system_object_mark_integrity_verified(): void public function test_storage_signed_url_service_generate_multiple_signed_urls(): void { - $service = new \App\Services\StorageSignedUrlService; + $service = new StorageSignedUrlService; $filePaths = [ 'test/file1.txt' => ['size' => 1000, 'type' => 'text/plain'], @@ -1620,7 +1626,7 @@ public function test_storage_signed_url_service_generate_multiple_signed_urls(): public function test_storage_signed_url_service_generate_multiple_signed_urls_with_custom_bucket(): void { - $service = new \App\Services\StorageSignedUrlService; + $service = new StorageSignedUrlService; $customBucket = 'custom-bucket'; $filePaths = [ @@ -1637,16 +1643,16 @@ public function test_storage_signed_url_service_generate_multiple_signed_urls_wi public function test_storage_signed_url_service_get_client(): void { - $service = new \App\Services\StorageSignedUrlService; + $service = new StorageSignedUrlService; $client = $service->getClient(); - $this->assertInstanceOf(\Aws\S3\S3Client::class, $client); + $this->assertInstanceOf(S3Client::class, $client); } public function test_path_generator_service_parse_directories(): void { - $service = new \App\Services\PathGeneratorService; + $service = new PathGeneratorService; $path = '/folder1/folder2/folder3/file.txt'; $filename = 'file.txt'; @@ -1660,7 +1666,7 @@ public function test_path_generator_service_parse_directories(): void public function test_path_generator_service_parse_directories_with_no_folders(): void { - $service = new \App\Services\PathGeneratorService; + $service = new PathGeneratorService; $path = '/file.txt'; $filename = 'file.txt'; @@ -1673,7 +1679,7 @@ public function test_path_generator_service_parse_directories_with_no_folders(): public function test_path_generator_service_has_directories_with_path(): void { - $service = new \App\Services\PathGeneratorService; + $service = new PathGeneratorService; $result = $service->hasDirectories('folder/file.txt', '/'); @@ -1682,7 +1688,7 @@ public function test_path_generator_service_has_directories_with_path(): void public function test_path_generator_service_has_directories_with_non_root_destination(): void { - $service = new \App\Services\PathGeneratorService; + $service = new PathGeneratorService; $result = $service->hasDirectories(null, '/folder'); @@ -1691,7 +1697,7 @@ public function test_path_generator_service_has_directories_with_non_root_destin public function test_path_generator_service_has_directories_returns_false(): void { - $service = new \App\Services\PathGeneratorService; + $service = new PathGeneratorService; $result = $service->hasDirectories(null, '/'); diff --git a/tests/Feature/ManageAuthorsTest.php b/tests/Feature/ManageAuthorsTest.php index dd2bca3bb..f5a9d0ee5 100644 --- a/tests/Feature/ManageAuthorsTest.php +++ b/tests/Feature/ManageAuthorsTest.php @@ -10,7 +10,9 @@ use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; +use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; +use Illuminate\Validation\ValidationException; use Tests\TestCase; class ManageAuthorsTest extends TestCase @@ -1056,7 +1058,7 @@ public function test_sync_authors_action_validates_required_fields(): void $updateProject = new UpdateProject; $syncProjectAuthors = new SyncProjectAuthors($updateProject); - $this->expectException(\Illuminate\Validation\ValidationException::class); + $this->expectException(ValidationException::class); $authorsData = [ [ 'given_name' => '', @@ -1144,7 +1146,7 @@ public function test_sync_authors_action_prevents_n_plus_one_queries(): void /** * Prepare request body for author * - * @param \App\Models\Author $author + * @param Author $author * @return array $body */ public function prepareBody($author) @@ -1181,8 +1183,8 @@ public function prepareBody($author) /** * Make Request to add author * - * @param \App\Models\Author $body - * @return \Illuminate\Http\Response + * @param Author $body + * @return Response */ public function addAuthor($body, $projectId) { @@ -1194,8 +1196,8 @@ public function addAuthor($body, $projectId) /** * Make Request to update author * - * @param \App\Models\Author $body - * @return \Illuminate\Http\Response + * @param Author $body + * @return Response */ public function updateAuthor($author, $projectId) { @@ -1222,8 +1224,8 @@ public function updateAuthor($author, $projectId) /** * Make Request to detach author * - * @param \App\Models\Author $body - * @return \Illuminate\Http\Response + * @param Author $body + * @return Response */ public function detachAuthor($body, $projectId) { diff --git a/tests/Feature/ManageCitationsTest.php b/tests/Feature/ManageCitationsTest.php index e849b576b..78fffc518 100644 --- a/tests/Feature/ManageCitationsTest.php +++ b/tests/Feature/ManageCitationsTest.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Http\Response; use Tests\TestCase; class ManageCitationsTest extends TestCase @@ -883,7 +884,7 @@ public function test_citation_destroy_requires_authentication() /** * Prepare request body for citation * - * @param \App\Models\Citation $citation + * @param Citation $citation * @return array $body */ public function prepareBody($citation) @@ -907,9 +908,9 @@ public function prepareBody($citation) /** * Make Request to update citation * - * @param \App\Models\Citation $citation + * @param Citation $citation * @param int $projectId - * @return \Illuminate\Http\Response + * @return Response */ public function updateCitation($body, $projectId) { @@ -921,9 +922,9 @@ public function updateCitation($body, $projectId) /** * Make Request to detach citation * - * @param \App\Models\Citation $citation + * @param Citation $citation * @param int $projectId - * @return \Illuminate\Http\Response + * @return Response */ public function detachCitation($body, $projectId) { diff --git a/tests/Feature/OrcidControllerTest.php b/tests/Feature/OrcidControllerTest.php index 656d30469..eae6f2fc5 100644 --- a/tests/Feature/OrcidControllerTest.php +++ b/tests/Feature/OrcidControllerTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use App\Http\Controllers\OrcidController; use Illuminate\Support\Facades\Http; use Tests\TestCase; @@ -335,7 +336,7 @@ public function test_endpoints_send_correct_accept_header(): void */ public function test_person_returns_error_when_orcid_id_is_empty(): void { - $controller = new \App\Http\Controllers\OrcidController; + $controller = new OrcidController; $response = $controller->person(''); $this->assertEquals(400, $response->status()); @@ -347,7 +348,7 @@ public function test_person_returns_error_when_orcid_id_is_empty(): void */ public function test_employment_returns_error_when_orcid_id_is_empty(): void { - $controller = new \App\Http\Controllers\OrcidController; + $controller = new OrcidController; $response = $controller->employment(''); $this->assertEquals(400, $response->status()); diff --git a/tests/Feature/Project/BasicProjectWorkflowTest.php b/tests/Feature/Project/BasicProjectWorkflowTest.php index bdd8a25e6..396ba5967 100644 --- a/tests/Feature/Project/BasicProjectWorkflowTest.php +++ b/tests/Feature/Project/BasicProjectWorkflowTest.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\Team; use App\Models\User; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -251,7 +252,7 @@ public function test_project_can_have_studies_attached() $project->users()->attach($this->user, ['role' => 'creator']); // Check that project has studies relationship - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $project->studies); + $this->assertInstanceOf(Collection::class, $project->studies); $this->assertEquals(0, $project->studies->count()); } @@ -269,7 +270,7 @@ public function test_project_has_correct_relationships() $this->assertInstanceOf(User::class, $project->owner); $this->assertInstanceOf(Team::class, $project->team); $this->assertInstanceOf(License::class, $project->license); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $project->users); + $this->assertInstanceOf(Collection::class, $project->users); $this->assertTrue($project->users->contains($this->user)); } } diff --git a/tests/Feature/Project/ProjectArchivalAndDeletionTest.php b/tests/Feature/Project/ProjectArchivalAndDeletionTest.php index 0d01ced3f..e41dfcf6e 100644 --- a/tests/Feature/Project/ProjectArchivalAndDeletionTest.php +++ b/tests/Feature/Project/ProjectArchivalAndDeletionTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\Project; use App\Events\ProjectArchival; +use App\Events\ProjectDeletion; use App\Models\Project; use App\Models\Team; use App\Models\User; @@ -10,6 +11,7 @@ use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; use Tests\TestCase; class ProjectArchivalAndDeletionTest extends TestCase @@ -98,7 +100,7 @@ public function test_project_owner_can_request_deletion_via_http() $this->project->refresh(); $this->assertTrue($this->project->is_deleted); - Event::assertDispatched(\App\Events\ProjectDeletion::class, function ($event) { + Event::assertDispatched(ProjectDeletion::class, function ($event) { return $event->project->id === $this->project->id; }); } @@ -210,7 +212,7 @@ public function test_project_archival_maintains_data_integrity() $study = $this->project->studies()->create([ 'name' => 'Test Study', 'slug' => 'test-study', - 'uuid' => \Illuminate\Support\Str::uuid(), + 'uuid' => Str::uuid(), 'owner_id' => $this->owner->id, ]); @@ -308,7 +310,7 @@ public function test_project_deletion_marks_project_and_studies_as_deleted() $study = $this->project->studies()->create([ 'name' => 'Test Study', 'slug' => 'test-study', - 'uuid' => \Illuminate\Support\Str::uuid(), + 'uuid' => Str::uuid(), 'owner_id' => $this->owner->id, ]); diff --git a/tests/Feature/Project/ProjectControllerAdditionalCoverageTest.php b/tests/Feature/Project/ProjectControllerAdditionalCoverageTest.php index ef3c170a5..d35c6751e 100644 --- a/tests/Feature/Project/ProjectControllerAdditionalCoverageTest.php +++ b/tests/Feature/Project/ProjectControllerAdditionalCoverageTest.php @@ -2,9 +2,11 @@ namespace Tests\Feature\Project; +use App\Http\Controllers\ProjectController; use App\Models\Draft; use App\Models\License; use App\Models\Project; +use App\Models\Sample; use App\Models\Study; use App\Models\User; use App\Models\Validation; @@ -77,7 +79,7 @@ public function test_public_studies_endpoint_returns_paginated_studies() ]); // Create a sample for each study - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->project->id, ]); @@ -91,7 +93,7 @@ public function test_public_studies_endpoint_returns_paginated_studies() ]); // Create sample for private study too - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $privateStudy->id, 'project_id' => $this->project->id, ]); @@ -126,7 +128,7 @@ public function test_public_studies_endpoint_filters_search_and_sort() ]); // Create a sample for the study - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->project->id, ]); @@ -251,7 +253,7 @@ public function test_reviewer_studies_endpoint_returns_studies() ]); // Create a sample for each study - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->privateProject->id, ]); @@ -281,7 +283,7 @@ public function test_reviewer_studies_handles_search_and_sort() ]); // Create a sample for the study - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->privateProject->id, ]); @@ -311,7 +313,7 @@ public function test_studies_endpoint_returns_all_project_studies() ]); // Create a sample for each study - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->privateProject->id, ]); @@ -445,7 +447,7 @@ public function test_prepare_send_list_method_with_creator_role() ]); // Use reflection to access private method - $controller = new \App\Http\Controllers\ProjectController; + $controller = new ProjectController; $reflection = new \ReflectionClass($controller); $method = $reflection->getMethod('prepareSendList'); $method->setAccessible(true); @@ -467,7 +469,7 @@ public function test_prepare_send_list_method_with_owner_role() 'updated_at' => now(), ]); - $controller = new \App\Http\Controllers\ProjectController; + $controller = new ProjectController; $reflection = new \ReflectionClass($controller); $method = $reflection->getMethod('prepareSendList'); $method->setAccessible(true); @@ -489,7 +491,7 @@ public function test_prepare_send_list_method_with_other_roles() 'updated_at' => now(), ]); - $controller = new \App\Http\Controllers\ProjectController; + $controller = new ProjectController; $reflection = new \ReflectionClass($controller); $method = $reflection->getMethod('prepareSendList'); $method->setAccessible(true); diff --git a/tests/Feature/Project/ProjectPublicViewTest.php b/tests/Feature/Project/ProjectPublicViewTest.php index fc939f46e..52313ae08 100644 --- a/tests/Feature/Project/ProjectPublicViewTest.php +++ b/tests/Feature/Project/ProjectPublicViewTest.php @@ -4,6 +4,7 @@ use App\Models\License; use App\Models\Project; +use App\Models\Sample; use App\Models\Study; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -64,7 +65,7 @@ public function test_public_project_samples_tab_view() $study = Study::factory()->for($this->publicProject)->create(); // Create a sample for the study to avoid null access in StudyResource - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->publicProject->id, ]); @@ -111,7 +112,7 @@ public function test_public_project_study_tab_view() ]); // Create a sample for the study to avoid null access in StudyResource - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->publicProject->id, ]); diff --git a/tests/Feature/Project/ProjectValidationTest.php b/tests/Feature/Project/ProjectValidationTest.php index 57a512335..2f9aa8206 100644 --- a/tests/Feature/Project/ProjectValidationTest.php +++ b/tests/Feature/Project/ProjectValidationTest.php @@ -4,6 +4,7 @@ use App\Models\Dataset; use App\Models\Project; +use App\Models\Sample; use App\Models\Study; use App\Models\User; use App\Models\Validation; @@ -59,7 +60,7 @@ public function test_validation_associates_with_studies_and_datasets() ]); // Create a sample for the study to avoid null access in Validation - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->project->id, ]); @@ -109,7 +110,7 @@ public function test_validation_processes_project_data() ]); // Create a sample for the study to avoid null access in Validation - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->project->id, ]); @@ -164,11 +165,11 @@ public function test_validation_handles_project_with_multiple_studies() ]); // Create samples for both studies to avoid null access in Validation - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study1->id, 'project_id' => $this->project->id, ]); - \App\Models\Sample::factory()->create([ + Sample::factory()->create([ 'study_id' => $study2->id, 'project_id' => $this->project->id, ]); diff --git a/tests/Feature/Project/PublishProjectTest.php b/tests/Feature/Project/PublishProjectTest.php index 1d771d1ce..3a1c90c46 100644 --- a/tests/Feature/Project/PublishProjectTest.php +++ b/tests/Feature/Project/PublishProjectTest.php @@ -2,6 +2,9 @@ namespace Tests\Feature\Project; +use App\Models\Citation; +use App\Models\Dataset; +use App\Models\Draft; use App\Models\License; use App\Models\Project; use App\Models\Sample; @@ -120,7 +123,7 @@ public function test_project_publication_updates_validation_status() #[Test] public function citations_without_doi_fail_validation(): void { - $citation = \App\Models\Citation::factory()->create([ + $citation = Citation::factory()->create([ 'doi' => null, ]); @@ -145,7 +148,7 @@ public function citations_without_doi_fail_validation(): void #[Test] public function citations_with_doi_pass_validation(): void { - $citation = \App\Models\Citation::factory()->create([ + $citation = Citation::factory()->create([ 'doi' => '10.1234/test.doi', ]); @@ -424,7 +427,7 @@ public function test_project_with_single_sample_can_be_published_as_sample() 'project_id' => $this->project->id, ]); - $draft = \App\Models\Draft::factory()->create([ + $draft = Draft::factory()->create([ 'name' => 'Test Draft', 'owner_id' => $this->user->id, 'project_enabled' => true, @@ -488,7 +491,7 @@ public function test_publishing_as_sample_disables_project_mode_in_draft() Queue::fake(); // Create a draft with project mode enabled - $draft = \App\Models\Draft::factory()->create([ + $draft = Draft::factory()->create([ 'name' => 'Test Draft', 'owner_id' => $this->user->id, 'project_enabled' => true, @@ -530,7 +533,7 @@ public function test_publishing_as_sample_applies_license_to_all_studies_and_dat 'project_id' => $this->project->id, 'license_id' => null, ]); - $dataset = \App\Models\Dataset::factory()->create([ + $dataset = Dataset::factory()->create([ 'study_id' => $study->id, 'project_id' => $this->project->id, 'license_id' => null, diff --git a/tests/Feature/Project/UpdateProjectTest.php b/tests/Feature/Project/UpdateProjectTest.php index 3f638cd56..1158370e5 100644 --- a/tests/Feature/Project/UpdateProjectTest.php +++ b/tests/Feature/Project/UpdateProjectTest.php @@ -6,6 +6,7 @@ use App\Models\Project; use App\Models\Team; use App\Models\User; +use Carbon\Carbon; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -435,7 +436,7 @@ public function test_project_owner_can_update_release_date_via_http() $this->project->refresh(); $this->assertEquals($releaseDate, $this->project->release_date ? - \Carbon\Carbon::parse($this->project->release_date)->format('Y-m-d') : null); + Carbon::parse($this->project->release_date)->format('Y-m-d') : null); } public function test_project_release_date_update_requires_authorization() @@ -495,6 +496,6 @@ public function test_project_release_date_can_be_updated_via_json() $this->project->refresh(); $this->assertEquals($releaseDate, $this->project->release_date ? - \Carbon\Carbon::parse($this->project->release_date)->format('Y-m-d H:i:s') : null); + Carbon::parse($this->project->release_date)->format('Y-m-d H:i:s') : null); } } diff --git a/tests/Feature/RorControllerTest.php b/tests/Feature/RorControllerTest.php index 7df7c3008..30a7c17f6 100644 --- a/tests/Feature/RorControllerTest.php +++ b/tests/Feature/RorControllerTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Http\Client\ConnectionException; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; use Tests\TestCase; @@ -170,7 +171,7 @@ public function test_search_handles_connection_timeout(): void { Http::fake([ config('ror.api_url').'*' => function () { - throw new \Illuminate\Http\Client\ConnectionException('Connection timeout'); + throw new ConnectionException('Connection timeout'); }, ]); diff --git a/tests/Feature/Study/PublishStudyTest.php b/tests/Feature/Study/PublishStudyTest.php index dbaad9bba..bcf3e6553 100644 --- a/tests/Feature/Study/PublishStudyTest.php +++ b/tests/Feature/Study/PublishStudyTest.php @@ -14,6 +14,7 @@ use App\Services\ChemotionRepositoryTrackerService; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Log; +use Illuminate\Validation\ValidationException; use Tests\TestCase; class PublishStudyTest extends TestCase @@ -81,7 +82,7 @@ public function test_study_cannot_be_published_without_license(): void $updater = new UpdateStudy; - $this->expectException(\Illuminate\Validation\ValidationException::class); + $this->expectException(ValidationException::class); $updater->update($study, [ 'name' => $study->name, diff --git a/tests/Feature/Study/StudyDataManagementTest.php b/tests/Feature/Study/StudyDataManagementTest.php index 0a9fd4f29..2a282c8a8 100644 --- a/tests/Feature/Study/StudyDataManagementTest.php +++ b/tests/Feature/Study/StudyDataManagementTest.php @@ -13,6 +13,7 @@ use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; use Tests\TestCase; class StudyDataManagementTest extends TestCase @@ -218,7 +219,7 @@ public function test_study_creates_sample_automatically(): void // Manually create sample to simulate the action behavior $sample = Sample::create([ 'name' => $newStudy->name.'_sample', - 'slug' => \Illuminate\Support\Str::slug($newStudy->name.'_sample', '-'), + 'slug' => Str::slug($newStudy->name.'_sample', '-'), 'study_id' => $newStudy->id, 'project_id' => $newStudy->project->id, ]); diff --git a/tests/Feature/Study/StudyIntegrationTest.php b/tests/Feature/Study/StudyIntegrationTest.php index 63114b9d5..3a1a3c2a3 100644 --- a/tests/Feature/Study/StudyIntegrationTest.php +++ b/tests/Feature/Study/StudyIntegrationTest.php @@ -6,11 +6,14 @@ use App\Models\Dataset; use App\Models\Molecule; use App\Models\Project; +use App\Models\Sample; use App\Models\Study; use App\Models\Team; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Cache; +use Maize\Markable\Models\Bookmark; +use Maize\Markable\Models\Like; use Tests\TestCase; class StudyIntegrationTest extends TestCase @@ -179,7 +182,7 @@ public function test_studies_filtered_by_molecule(): void ]); // Associate molecule with first study through sample - $sample = \App\Models\Sample::factory()->create(['study_id' => $studyWithMolecule->id]); + $sample = Sample::factory()->create(['study_id' => $studyWithMolecule->id]); $sample->molecules()->attach($molecule); $this->get(route('public.spectra', ['compound' => '123'])) @@ -398,16 +401,16 @@ public function test_study_markable_system_integration(): void $this->actingAs($this->user); // Test bookmarking - \Maize\Markable\Models\Bookmark::add($study, $this->user); - $this->assertTrue(\Maize\Markable\Models\Bookmark::has($study, $this->user)); + Bookmark::add($study, $this->user); + $this->assertTrue(Bookmark::has($study, $this->user)); // Test liking - \Maize\Markable\Models\Like::add($study, $this->user); - $this->assertTrue(\Maize\Markable\Models\Like::has($study, $this->user)); + Like::add($study, $this->user); + $this->assertTrue(Like::has($study, $this->user)); // Test unmarking - \Maize\Markable\Models\Bookmark::remove($study, $this->user); - $this->assertFalse(\Maize\Markable\Models\Bookmark::has($study, $this->user)); + Bookmark::remove($study, $this->user); + $this->assertFalse(Bookmark::has($study, $this->user)); } public function test_study_cross_model_relationships(): void @@ -419,7 +422,7 @@ public function test_study_cross_model_relationships(): void ]); // Create related models - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); $datasets = Dataset::factory(2)->create(['study_id' => $study->id]); $molecules = Molecule::factory(2)->create(); $sample->molecules()->attach($molecules); diff --git a/tests/Feature/Study/StudyMailTest.php b/tests/Feature/Study/StudyMailTest.php index fdd755a33..01e7e9542 100644 --- a/tests/Feature/Study/StudyMailTest.php +++ b/tests/Feature/Study/StudyMailTest.php @@ -10,6 +10,7 @@ use App\Models\Team; use App\Models\User; use Carbon\Carbon; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -83,7 +84,7 @@ public function test_study_invitation_mail_is_queueable(): void $mailable = new StudyInvitation($invitation); - $this->assertInstanceOf(\Illuminate\Contracts\Queue\ShouldQueue::class, $mailable); + $this->assertInstanceOf(ShouldQueue::class, $mailable); } public function test_study_publish_mail_can_be_rendered(): void diff --git a/tests/Feature/Study/StudyRelationshipsTest.php b/tests/Feature/Study/StudyRelationshipsTest.php index af63957cf..1bf14a477 100644 --- a/tests/Feature/Study/StudyRelationshipsTest.php +++ b/tests/Feature/Study/StudyRelationshipsTest.php @@ -17,6 +17,7 @@ use App\Models\Validation; use Illuminate\Database\Eloquent\Collection; use Illuminate\Foundation\Testing\RefreshDatabase; +use Maize\Markable\Models\Bookmark; use Tests\TestCase; class StudyRelationshipsTest extends TestCase @@ -312,7 +313,7 @@ public function test_study_is_bookmarked_attribute(): void $this->assertFalse($this->study->is_bookmarked); // Bookmark the study - \Maize\Markable\Models\Bookmark::add($this->study, $this->user); + Bookmark::add($this->study, $this->user); $this->study->refresh(); $this->assertTrue($this->study->is_bookmarked); diff --git a/tests/Feature/SupportBubbleTest.php b/tests/Feature/SupportBubbleTest.php index 726682a4f..d8923aa65 100644 --- a/tests/Feature/SupportBubbleTest.php +++ b/tests/Feature/SupportBubbleTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature; +use Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent; use Tests\TestCase; class SupportBubbleTest extends TestCase @@ -210,13 +211,13 @@ public function test_message_too_short_is_rejected(): void public function test_exception_handling_when_event_fails(): void { // Mock the SupportBubbleSubmittedEvent to throw an exception when constructed - $this->mock(\Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent::class, function ($mock) { + $this->mock(SupportBubbleSubmittedEvent::class, function ($mock) { $mock->shouldReceive('__construct') ->andThrow(new \Exception('Event construction failed')); }); // Listen for the event and throw an exception - \Event::listen(\Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent::class, function () { + \Event::listen(SupportBubbleSubmittedEvent::class, function () { throw new \Exception('Event listener failed'); }); @@ -245,7 +246,7 @@ public function test_exception_is_logged_with_details(): void \Log::spy(); // Listen for the event and throw an exception - \Event::listen(\Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent::class, function () { + \Event::listen(SupportBubbleSubmittedEvent::class, function () { throw new \Exception('Event listener failed'); }); @@ -290,7 +291,7 @@ public function test_successful_submission_fires_event_with_correct_parameters() $response->assertStatus(200); - \Event::assertDispatched(\Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent::class, function ($event) use ($validData) { + \Event::assertDispatched(SupportBubbleSubmittedEvent::class, function ($event) use ($validData) { return $event->subject === $validData['subject'] && $event->message === $validData['message'] && $event->email === $validData['email'] @@ -317,7 +318,7 @@ public function test_successful_submission_without_name_field(): void $response->assertStatus(200); - \Event::assertDispatched(\Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent::class); + \Event::assertDispatched(SupportBubbleSubmittedEvent::class); } /** @@ -340,7 +341,7 @@ public function test_ip_and_user_agent_captured_in_event(): void $response->assertStatus(200); - \Event::assertDispatched(\Spatie\SupportBubble\Events\SupportBubbleSubmittedEvent::class, function ($event) { + \Event::assertDispatched(SupportBubbleSubmittedEvent::class, function ($event) { return ! empty($event->ip) && ! empty($event->userAgent); }); } diff --git a/tests/Feature/Team/TeamMailTest.php b/tests/Feature/Team/TeamMailTest.php index a2c89fbe7..9da6c237a 100644 --- a/tests/Feature/Team/TeamMailTest.php +++ b/tests/Feature/Team/TeamMailTest.php @@ -6,6 +6,7 @@ use App\Models\Team; use App\Models\TeamInvitation as TeamInvitationModel; use App\Models\User; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -64,7 +65,7 @@ public function test_team_invitation_mail_is_queueable(): void $mailable = new TeamInvitation($invitation); - $this->assertInstanceOf(\Illuminate\Contracts\Queue\ShouldQueue::class, $mailable); + $this->assertInstanceOf(ShouldQueue::class, $mailable); } public function test_team_invitation_mail_handles_different_roles(): void diff --git a/tests/Feature/UploadTest.php b/tests/Feature/UploadTest.php index f06571a7a..92c8a7267 100644 --- a/tests/Feature/UploadTest.php +++ b/tests/Feature/UploadTest.php @@ -5,6 +5,7 @@ use App\Models\Draft; use App\Models\Project; use App\Models\User; +use App\Models\Validation; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -115,7 +116,7 @@ public function test_publish_requires_authorization(): void public function test_publish_renders_for_authorized_user(): void { - $validation = \App\Models\Validation::factory()->create(); + $validation = Validation::factory()->create(); $draft = Draft::factory()->create([ 'owner_id' => $this->user->id, 'team_id' => $this->user->currentTeam->id, @@ -136,7 +137,7 @@ public function test_publish_renders_for_authorized_user(): void public function test_publish_processes_project_validation(): void { - $validation = \App\Models\Validation::factory()->create(); + $validation = Validation::factory()->create(); $draft = Draft::factory()->create([ 'owner_id' => $this->user->id, 'team_id' => $this->user->currentTeam->id, @@ -157,7 +158,7 @@ public function test_publish_processes_project_validation(): void public function test_publish_queries_project_by_draft_id(): void { - $validation = \App\Models\Validation::factory()->create(); + $validation = Validation::factory()->create(); $draft = Draft::factory()->create([ 'owner_id' => $this->user->id, 'team_id' => $this->user->currentTeam->id, @@ -179,7 +180,7 @@ public function test_publish_queries_project_by_draft_id(): void public function test_publish_checks_gate_for_user(): void { - $validation = \App\Models\Validation::factory()->create(); + $validation = Validation::factory()->create(); $draft = Draft::factory()->create([ 'owner_id' => $this->user->id, 'team_id' => $this->user->currentTeam->id, @@ -261,7 +262,7 @@ public function test_upload_handles_invalid_step(): void public function test_publish_loads_project_with_relationships(): void { - $validation = \App\Models\Validation::factory()->create(); + $validation = Validation::factory()->create(); $draft = Draft::factory()->create([ 'owner_id' => $this->user->id, 'team_id' => $this->user->currentTeam->id, diff --git a/tests/Unit/Actions/Project/AddProjectMemberTest.php b/tests/Unit/Actions/Project/AddProjectMemberTest.php index 5a7eab2db..7da1c7078 100644 --- a/tests/Unit/Actions/Project/AddProjectMemberTest.php +++ b/tests/Unit/Actions/Project/AddProjectMemberTest.php @@ -7,6 +7,7 @@ use App\Events\ProjectMemberAdded; use App\Models\Project; use App\Models\User; +use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Gate; @@ -70,7 +71,7 @@ public function test_cannot_add_member_without_authorization() $unauthorizedUser = User::factory()->withPersonalTeam()->create(); $newMember = User::factory()->withPersonalTeam()->create(); - $this->expectException(\Illuminate\Auth\Access\AuthorizationException::class); + $this->expectException(AuthorizationException::class); $this->action->add($unauthorizedUser, $this->project, $newMember->email, 'reviewer'); } diff --git a/tests/Unit/Actions/Project/AssignIdentifierTest.php b/tests/Unit/Actions/Project/AssignIdentifierTest.php index 4aa565f27..6dd2b3efa 100644 --- a/tests/Unit/Actions/Project/AssignIdentifierTest.php +++ b/tests/Unit/Actions/Project/AssignIdentifierTest.php @@ -3,6 +3,7 @@ namespace Tests\Unit\Actions\Project; use App\Actions\Project\AssignIdentifier; +use App\Models\License; use App\Models\Project; use App\Models\Study; use App\Models\Ticker; @@ -49,7 +50,7 @@ public function test_constructor_accepts_doi_service() public function test_assign_creates_project_identifier_when_missing() { - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); $project = Project::factory()->create(['identifier' => null, 'license_id' => $license->id]); $this->action->assign($project); @@ -66,7 +67,7 @@ public function test_assign_creates_project_identifier_when_missing() public function test_assign_does_not_overwrite_existing_project_identifier() { - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); $project = Project::factory()->create(['identifier' => 999, 'license_id' => $license->id]); $this->action->assign($project); @@ -82,7 +83,7 @@ public function test_assign_does_not_overwrite_existing_project_identifier() public function test_assign_processes_tickers_correctly() { - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); // Create first project $project1 = Project::factory()->create(['identifier' => null, 'license_id' => $license->id]); @@ -159,7 +160,7 @@ public function test_assign_action_exists_and_is_callable() public function test_assign_handles_mixed_existing_and_new_identifiers() { - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); // Test with existing identifier $existingProject = Project::factory()->create(['identifier' => 100, 'license_id' => $license->id]); diff --git a/tests/Unit/Actions/Project/DeleteProjectTest.php b/tests/Unit/Actions/Project/DeleteProjectTest.php index 22d7f5fa3..ba4124894 100644 --- a/tests/Unit/Actions/Project/DeleteProjectTest.php +++ b/tests/Unit/Actions/Project/DeleteProjectTest.php @@ -17,6 +17,7 @@ use App\Models\Validation; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Storage; +use Spatie\Permission\Models\Role; use Tests\TestCase; class DeleteProjectTest extends TestCase @@ -115,7 +116,7 @@ public function test_prepare_send_list_includes_creators_and_owners() public function test_permanent_delete_removes_all_objects() { // Create super-admin role for test - \Spatie\Permission\Models\Role::create(['name' => 'super-admin', 'guard_name' => 'web']); + Role::create(['name' => 'super-admin', 'guard_name' => 'web']); $project = Project::factory()->create(['is_public' => false]); $study = Study::factory()->for($project)->create(); diff --git a/tests/Unit/Actions/Project/UpdateDOITest.php b/tests/Unit/Actions/Project/UpdateDOITest.php index 27eabcdae..c95ccb4ee 100644 --- a/tests/Unit/Actions/Project/UpdateDOITest.php +++ b/tests/Unit/Actions/Project/UpdateDOITest.php @@ -4,6 +4,7 @@ use App\Actions\Project\UpdateDOI; use App\Models\Dataset; +use App\Models\License; use App\Models\Project; use App\Models\Study; use App\Services\DOI\DOIService; @@ -301,7 +302,7 @@ public function test_update_action_exists_and_is_callable() public function test_update_handles_project_without_studies() { // Create license first - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); $project = Project::factory()->create(['license_id' => $license->id]); $project->studies()->delete(); // Ensure no studies exist @@ -313,7 +314,7 @@ public function test_update_handles_project_without_studies() public function test_update_handles_study_without_datasets() { // Create license and project first - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); $project = Project::factory()->create(['license_id' => $license->id]); $study = Study::factory()->create(['project_id' => $project->id, 'license_id' => $license->id]); $study->datasets()->delete(); // Ensure no datasets exist @@ -327,7 +328,7 @@ public function test_update_handles_study_without_datasets() public function test_update_with_mock_doi_service_completes_successfully() { // Create license first - $license = \App\Models\License::factory()->create(); + $license = License::factory()->create(); // Create a project with nested relationships $project = Project::factory()->create(['license_id' => $license->id]); diff --git a/tests/Unit/Jobs/DeleteProjectsJobTest.php b/tests/Unit/Jobs/DeleteProjectsJobTest.php index 4d3d80f65..3ff6631ff 100644 --- a/tests/Unit/Jobs/DeleteProjectsJobTest.php +++ b/tests/Unit/Jobs/DeleteProjectsJobTest.php @@ -5,6 +5,7 @@ use App\Actions\Project\DeleteProject; use App\Jobs\DeleteProjects; use App\Models\Project; +use App\Models\User; use App\Notifications\ProjectDeletionReminderNotification; use Carbon\Carbon; use Illuminate\Contracts\Queue\ShouldQueue; @@ -24,7 +25,7 @@ protected function setUp(): void { parent::setUp(); - $user = \App\Models\User::factory()->create(); + $user = User::factory()->create(); $this->project = Project::factory()->create([ 'owner_id' => $user->id, 'is_deleted' => true, @@ -230,7 +231,7 @@ public function test_job_can_be_pushed_to_specific_queue(): void public function test_prepare_send_list_adds_project_owner_for_non_creator_members(): void { // Test line 69 - adds project owner for non-creator members - $member = \App\Models\User::factory()->create(); + $member = User::factory()->create(); $this->project->users()->attach($member, ['role' => 'collaborator']); $job = new DeleteProjects($this->project); diff --git a/tests/Unit/Jobs/ProcessDraftELNSubmissionProxyTest.php b/tests/Unit/Jobs/ProcessDraftELNSubmissionProxyTest.php index c8f01ed92..4a7f9db0b 100644 --- a/tests/Unit/Jobs/ProcessDraftELNSubmissionProxyTest.php +++ b/tests/Unit/Jobs/ProcessDraftELNSubmissionProxyTest.php @@ -2,8 +2,10 @@ namespace Tests\Unit\Jobs; +use App\Actions\Draft\DraftProcessingLogger; use App\Jobs\ProcessDraftELNSubmission; use App\Models\Draft; +use App\Services\PathGeneratorService; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Http; @@ -40,12 +42,12 @@ public function test_http_client_uses_proxy_when_configured(): void $method->setAccessible(true); // Mock the PathGeneratorService - $pathGenerator = $this->createMock(\App\Services\PathGeneratorService::class); + $pathGenerator = $this->createMock(PathGeneratorService::class); $pathGenerator->method('generateDraftFilePath') ->willReturn('test/path/file.txt'); // Mock the DraftProcessingLogger (actual class lives under App\Actions\Draft) - $logger = $this->createMock(\App\Actions\Draft\DraftProcessingLogger::class); + $logger = $this->createMock(DraftProcessingLogger::class); try { // This will fail because we're not actually extracting a real zip, @@ -88,12 +90,12 @@ public function test_http_client_works_without_proxy_configuration(): void $method->setAccessible(true); // Mock the PathGeneratorService - $pathGenerator = $this->createMock(\App\Services\PathGeneratorService::class); + $pathGenerator = $this->createMock(PathGeneratorService::class); $pathGenerator->method('generateDraftFilePath') ->willReturn('test/path/file.txt'); // Mock the DraftProcessingLogger (actual class lives under App\Actions\Draft) - $logger = $this->createMock(\App\Actions\Draft\DraftProcessingLogger::class); + $logger = $this->createMock(DraftProcessingLogger::class); try { // This will fail because we're not actually extracting a real zip, diff --git a/tests/Unit/Jobs/ProcessELNSpectraTest.php b/tests/Unit/Jobs/ProcessELNSpectraTest.php index 269d10223..d5f73f6d8 100644 --- a/tests/Unit/Jobs/ProcessELNSpectraTest.php +++ b/tests/Unit/Jobs/ProcessELNSpectraTest.php @@ -6,6 +6,7 @@ use App\Models\NMRium; use App\Models\Project; use App\Models\Study; +use App\Models\User; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Http; @@ -25,7 +26,7 @@ protected function setUp(): void { parent::setUp(); - $user = \App\Models\User::factory()->create(); + $user = User::factory()->create(); $this->project = Project::factory()->create([ 'owner_id' => $user->id, ]); diff --git a/tests/Unit/Jobs/ProcessProjectJobTest.php b/tests/Unit/Jobs/ProcessProjectJobTest.php index 422f5b2d0..698f5864a 100644 --- a/tests/Unit/Jobs/ProcessProjectJobTest.php +++ b/tests/Unit/Jobs/ProcessProjectJobTest.php @@ -9,6 +9,7 @@ use App\Models\Draft; use App\Models\FileSystemObject; use App\Models\Project; +use App\Models\User; use App\Notifications\DraftProcessedNotification; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; @@ -30,7 +31,7 @@ protected function setUp(): void { parent::setUp(); - $user = \App\Models\User::factory()->create(); + $user = User::factory()->create(); $this->project = Project::factory()->create([ 'owner_id' => $user->id, 'status' => 'pending', diff --git a/tests/Unit/Jobs/ProcessSubmissionTest.php b/tests/Unit/Jobs/ProcessSubmissionTest.php index 387fe3004..6a046bc9b 100644 --- a/tests/Unit/Jobs/ProcessSubmissionTest.php +++ b/tests/Unit/Jobs/ProcessSubmissionTest.php @@ -12,11 +12,13 @@ use App\Models\FileSystemObject; use App\Models\Project; use App\Models\Study; +use App\Models\User; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; use Mockery; use Tests\TestCase; @@ -32,7 +34,7 @@ protected function setUp(): void { parent::setUp(); - $user = \App\Models\User::factory()->create(); + $user = User::factory()->create(); $this->project = Project::factory()->create([ 'owner_id' => $user->id, 'status' => 'queued', @@ -99,8 +101,8 @@ public function test_handle_deletes_project_after_study_mode_processing(): void 'type' => 'directory', 'name' => 'study', 'slug' => 'study', - 'key' => \Illuminate\Support\Str::uuid()->toString(), - 'uuid' => \Illuminate\Support\Str::uuid()->toString(), + 'key' => Str::uuid()->toString(), + 'uuid' => Str::uuid()->toString(), 'path' => $this->draft->path, 'status' => 'present', ]); @@ -146,8 +148,8 @@ public function test_handle_clears_dataset_draft_and_project_ids(): void 'type' => 'directory', 'name' => 'study', 'slug' => 'study', - 'key' => \Illuminate\Support\Str::uuid()->toString(), - 'uuid' => \Illuminate\Support\Str::uuid()->toString(), + 'key' => Str::uuid()->toString(), + 'uuid' => Str::uuid()->toString(), 'path' => $this->draft->path, 'status' => 'present', ]); @@ -192,8 +194,8 @@ public function test_move_folder_updates_nested_file_structure(): void 'type' => 'directory', 'name' => 'parent', 'slug' => 'parent', - 'key' => \Illuminate\Support\Str::uuid()->toString(), - 'uuid' => \Illuminate\Support\Str::uuid()->toString(), + 'key' => Str::uuid()->toString(), + 'uuid' => Str::uuid()->toString(), 'path' => $draftPath.'/parent', 'status' => 'present', ]); @@ -204,8 +206,8 @@ public function test_move_folder_updates_nested_file_structure(): void 'type' => 'file', 'name' => 'child.txt', 'slug' => 'child-txt', - 'key' => \Illuminate\Support\Str::uuid()->toString(), - 'uuid' => \Illuminate\Support\Str::uuid()->toString(), + 'key' => Str::uuid()->toString(), + 'uuid' => Str::uuid()->toString(), 'path' => $draftPath.'/parent/child.txt', 'parent_id' => $parentFolder->id, 'status' => 'present', @@ -228,7 +230,7 @@ public function test_move_folder_updates_nested_file_structure(): void public function test_prepare_send_list_returns_creators_and_owners(): void { - $creator = \App\Models\User::factory()->create(); + $creator = User::factory()->create(); $this->project->users()->attach($creator, ['role' => 'creator']); $job = new ProcessSubmission($this->project); diff --git a/tests/Unit/Models/AuthorModelTest.php b/tests/Unit/Models/AuthorModelTest.php index 454baa4ce..6d0bb1652 100644 --- a/tests/Unit/Models/AuthorModelTest.php +++ b/tests/Unit/Models/AuthorModelTest.php @@ -4,6 +4,7 @@ use App\Models\Author; use App\Models\Project; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -84,7 +85,7 @@ public function test_projects_relationship_is_many_to_many(): void { $author = Author::factory()->create(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $author->projects()); + $this->assertInstanceOf(BelongsToMany::class, $author->projects()); } public function test_author_can_be_attached_to_project(): void diff --git a/tests/Unit/Models/CitationModelTest.php b/tests/Unit/Models/CitationModelTest.php index bf5607b55..e1005dfff 100644 --- a/tests/Unit/Models/CitationModelTest.php +++ b/tests/Unit/Models/CitationModelTest.php @@ -4,6 +4,8 @@ use App\Models\Citation; use App\Models\Project; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -19,7 +21,7 @@ public function test_it_belongs_to_many_projects() $citation->projects()->attach([$project1->id, $project2->id]); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $citation->projects); + $this->assertInstanceOf(Collection::class, $citation->projects); $this->assertCount(2, $citation->projects); $this->assertTrue($citation->projects->contains($project1)); $this->assertTrue($citation->projects->contains($project2)); @@ -71,7 +73,7 @@ public function test_projects_relationship_is_many_to_many() $citation = Citation::factory()->create(); $relationship = $citation->projects(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); } public function test_citation_can_be_attached_to_project() diff --git a/tests/Unit/Models/DatasetModelTest.php b/tests/Unit/Models/DatasetModelTest.php index 002ea7172..a5ce2eebd 100644 --- a/tests/Unit/Models/DatasetModelTest.php +++ b/tests/Unit/Models/DatasetModelTest.php @@ -9,8 +9,10 @@ use App\Models\NMRium; use App\Models\Project; use App\Models\Study; +use App\Models\Team; use App\Models\User; use App\Models\Validation; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Storage; use Tests\TestCase; @@ -258,9 +260,9 @@ public function test_it_belongs_to_a_team(): void $dataset = Dataset::factory()->create(); $relationship = $dataset->team(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $relationship); + $this->assertInstanceOf(BelongsTo::class, $relationship); $this->assertEquals('Team_id', $relationship->getForeignKeyName()); - $this->assertEquals(\App\Models\Team::class, $relationship->getRelated()::class); + $this->assertEquals(Team::class, $relationship->getRelated()::class); } public function test_it_has_one_nmrium(): void diff --git a/tests/Unit/Models/DraftModelTest.php b/tests/Unit/Models/DraftModelTest.php index 3658fb2c0..912c7dc6e 100644 --- a/tests/Unit/Models/DraftModelTest.php +++ b/tests/Unit/Models/DraftModelTest.php @@ -6,6 +6,11 @@ use App\Models\Project; use App\Models\Team; use App\Models\User; +use Carbon\Carbon; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -46,10 +51,10 @@ public function test_it_has_many_files() // Test the relationship exists and is correct type $relationship = $draft->files(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $relationship); + $this->assertInstanceOf(HasMany::class, $relationship); // Test initial empty collection - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $draft->files); + $this->assertInstanceOf(Collection::class, $draft->files); $this->assertCount(0, $draft->files); } @@ -114,7 +119,7 @@ public function test_it_casts_release_date_to_date() { $draft = Draft::factory()->create(['release_date' => '2023-12-25']); - $this->assertInstanceOf(\Carbon\Carbon::class, $draft->release_date); + $this->assertInstanceOf(Carbon::class, $draft->release_date); $this->assertEquals('2023-12-25', $draft->release_date->format('Y-m-d')); } @@ -123,7 +128,7 @@ public function test_owner_relationship_is_belongs_to() $draft = Draft::factory()->create(); $relationship = $draft->owner(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $relationship); + $this->assertInstanceOf(BelongsTo::class, $relationship); } public function test_team_relationship_is_belongs_to() @@ -131,7 +136,7 @@ public function test_team_relationship_is_belongs_to() $draft = Draft::factory()->create(); $relationship = $draft->team(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $relationship); + $this->assertInstanceOf(BelongsTo::class, $relationship); } public function test_project_relationship_is_has_one() @@ -139,7 +144,7 @@ public function test_project_relationship_is_has_one() $draft = Draft::factory()->create(); $relationship = $draft->project(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasOne::class, $relationship); + $this->assertInstanceOf(HasOne::class, $relationship); } public function test_files_relationship_is_has_many() @@ -147,7 +152,7 @@ public function test_files_relationship_is_has_many() $draft = Draft::factory()->create(); $relationship = $draft->files(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $relationship); + $this->assertInstanceOf(HasMany::class, $relationship); } public function test_it_uses_has_factory_trait() diff --git a/tests/Unit/Models/FileSystemObjectModelTest.php b/tests/Unit/Models/FileSystemObjectModelTest.php index 6831c942d..0c86fbc9c 100644 --- a/tests/Unit/Models/FileSystemObjectModelTest.php +++ b/tests/Unit/Models/FileSystemObjectModelTest.php @@ -6,6 +6,9 @@ use App\Models\FileSystemObject; use App\Models\Project; use App\Models\Study; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -80,7 +83,7 @@ public function test_it_has_parent_child_relationships() $this->assertInstanceOf(FileSystemObject::class, $child->parent); $this->assertEquals($parent->id, $child->parent->id); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $parent->children); + $this->assertInstanceOf(Collection::class, $parent->children); $this->assertCount(1, $parent->children); $this->assertTrue($parent->children->contains($child)); } @@ -246,11 +249,11 @@ public function test_relationship_types() { $fsObject = new FileSystemObject; - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $fsObject->children()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $fsObject->parent()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $fsObject->project()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $fsObject->draft()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $fsObject->study()); + $this->assertInstanceOf(HasMany::class, $fsObject->children()); + $this->assertInstanceOf(BelongsTo::class, $fsObject->parent()); + $this->assertInstanceOf(BelongsTo::class, $fsObject->project()); + $this->assertInstanceOf(BelongsTo::class, $fsObject->draft()); + $this->assertInstanceOf(BelongsTo::class, $fsObject->study()); } public function test_boolean_fields_work_correctly() diff --git a/tests/Unit/Models/HasDOIModelTest.php b/tests/Unit/Models/HasDOIModelTest.php index c2b0c2d97..89eb121f0 100644 --- a/tests/Unit/Models/HasDOIModelTest.php +++ b/tests/Unit/Models/HasDOIModelTest.php @@ -2,10 +2,14 @@ namespace Tests\Unit\Models; +use App\Models\Author; +use App\Models\Citation; use App\Models\Dataset; use App\Models\License; use App\Models\Project; use App\Models\Study; +use App\Models\User; +use App\Services\DOI\DOIService; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -377,7 +381,7 @@ public function test_get_metadata_creators_array_structure(): void $project = Project::factory()->create(['license_id' => $license->id]); // Create project with authors to test creators array - $author = \App\Models\Author::factory()->create([ + $author = Author::factory()->create([ 'given_name' => 'John', 'family_name' => 'Doe', 'orcid_id' => '0000-0002-1825-0097', @@ -427,7 +431,7 @@ public function test_get_metadata_related_identifiers_structure(): void $project = Project::factory()->create(['license_id' => $license->id]); // Create citation to test related identifiers - $citation = \App\Models\Citation::factory()->create([ + $citation = Citation::factory()->create([ 'doi' => '10.1234/test.citation', ]); @@ -533,7 +537,7 @@ public function test_add_related_identifiers_for_project(): void ]); // Create mock DOI service - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/project', $this->isType('array')) @@ -560,7 +564,7 @@ public function test_add_related_identifiers_for_study(): void 'doi' => '10.1234/study', ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/study', $this->isType('array')) @@ -592,7 +596,7 @@ public function test_add_related_identifiers_for_dataset(): void 'doi' => '10.1234/dataset', ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/dataset', $this->isType('array')) @@ -615,7 +619,7 @@ public function test_generate_doi_for_project_with_doi_host(): void 'doi' => null, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('createDOI') ->with('P123', $this->isType('array')) @@ -646,7 +650,7 @@ public function test_generate_doi_for_study_with_project(): void 'doi' => null, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('createDOI') ->with('P456.S789', $this->isType('array')) @@ -665,7 +669,7 @@ public function test_generate_doi_for_study_without_project(): void putenv('DOI_HOST=https://api.datacite.org'); $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'project_id' => null, 'license_id' => $license->id, @@ -674,7 +678,7 @@ public function test_generate_doi_for_study_without_project(): void 'owner_id' => $owner->id, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('createDOI') ->with('S999', $this->isType('array')) @@ -711,7 +715,7 @@ public function test_generate_doi_for_dataset_with_project(): void 'doi' => null, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('createDOI') ->with('P111.S222.D333', $this->isType('array')) @@ -730,7 +734,7 @@ public function test_generate_doi_for_dataset_without_project(): void putenv('DOI_HOST=https://api.datacite.org'); $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'project_id' => null, 'identifier' => 444, @@ -745,7 +749,7 @@ public function test_generate_doi_for_dataset_without_project(): void 'doi' => null, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('createDOI') ->with('S444.D555', $this->isType('array')) @@ -764,14 +768,14 @@ public function test_update_doi_metadata_with_existing_doi(): void putenv('DOI_HOST=https://api.datacite.org'); $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'license_id' => $license->id, 'doi' => '10.1234/existing.doi', 'owner_id' => $owner->id, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/existing.doi', $this->isType('array')) @@ -795,7 +799,7 @@ public function test_update_doi_metadata_with_null_doi(): void 'doi' => null, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->never()) ->method('updateDOI'); @@ -810,7 +814,7 @@ public function test_get_metadata_with_study_without_project(): void { // Test getMetadata for Study without project - covers different branches $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'name' => 'Standalone Study', 'description' => 'Study without project', @@ -831,7 +835,7 @@ public function test_get_metadata_with_dataset_without_project(): void { // Test getMetadata for Dataset without project - covers different branches $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'name' => 'Study Name', 'project_id' => null, @@ -895,7 +899,7 @@ public function test_add_related_identifiers_for_study_without_project(): void { // Test addRelatedIdentifiers for Study without project - covers different branch $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'project_id' => null, 'license_id' => $license->id, @@ -903,7 +907,7 @@ public function test_add_related_identifiers_for_study_without_project(): void 'owner_id' => $owner->id, ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/standalone.study', $this->isType('array')) @@ -918,7 +922,7 @@ public function test_add_related_identifiers_for_dataset_without_project(): void { // Test addRelatedIdentifiers for Dataset without project - covers different branch $license = License::factory()->create(); - $owner = \App\Models\User::factory()->create(); + $owner = User::factory()->create(); $study = Study::factory()->create([ 'project_id' => null, 'license_id' => $license->id, @@ -933,7 +937,7 @@ public function test_add_related_identifiers_for_dataset_without_project(): void 'doi' => '10.1234/dataset', ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/dataset', $this->isType('array')) @@ -966,7 +970,7 @@ public function test_add_related_identifiers_for_project_with_studies_and_datase 'doi' => '10.1234/project.dataset', ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/main.project', $this->callback(function ($attributes) { @@ -1007,7 +1011,7 @@ public function test_add_related_identifiers_for_study_with_project_and_datasets 'doi' => '10.1234/study.dataset', ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/study.with.project', $this->callback(function ($attributes) { @@ -1048,7 +1052,7 @@ public function test_add_related_identifiers_covers_dataset_branch_lines(): void 'doi' => '10.1234/test.dataset', ]); - $doiService = $this->createMock(\App\Services\DOI\DOIService::class); + $doiService = $this->createMock(DOIService::class); $doiService->expects($this->once()) ->method('updateDOI') ->with('10.1234/test.dataset', $this->callback(function ($attributes) { diff --git a/tests/Unit/Models/HasProjectsTraitTest.php b/tests/Unit/Models/HasProjectsTraitTest.php index 6615e623d..4f67edbcd 100644 --- a/tests/Unit/Models/HasProjectsTraitTest.php +++ b/tests/Unit/Models/HasProjectsTraitTest.php @@ -2,9 +2,12 @@ namespace Tests\Unit\Models; +use App\Models\Draft; use App\Models\Project; use App\Models\Team; use App\Models\User; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -23,7 +26,7 @@ public function test_projects_relationship_exists(): void $user = User::factory()->create(); $this->assertTrue(method_exists($user, 'projects')); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->projects()); + $this->assertInstanceOf(BelongsToMany::class, $user->projects()); } public function test_active_projects_relationship_exists(): void @@ -31,7 +34,7 @@ public function test_active_projects_relationship_exists(): void $user = User::factory()->create(); $this->assertTrue(method_exists($user, 'activeProjects')); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->activeProjects()); + $this->assertInstanceOf(BelongsToMany::class, $user->activeProjects()); } public function test_active_projects_filters_deleted_projects(): void @@ -75,7 +78,7 @@ public function test_shared_drafts_method_exists(): void // Test with no shared projects - should return empty collection $sharedDrafts = $user->sharedDrafts(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $sharedDrafts); + $this->assertInstanceOf(Collection::class, $sharedDrafts); } public function test_recent_projects_orders_by_updated_at(): void @@ -83,7 +86,7 @@ public function test_recent_projects_orders_by_updated_at(): void $user = User::factory()->create(); $this->assertTrue(method_exists($user, 'recentProjects')); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->recentProjects()); + $this->assertInstanceOf(BelongsToMany::class, $user->recentProjects()); } public function test_belongs_to_project_returns_false_for_null_project(): void @@ -236,7 +239,7 @@ public function test_shared_drafts_returns_drafts_from_shared_projects(): void { $user = User::factory()->create(); $sharedProject = Project::factory()->create(); - $draft = \App\Models\Draft::factory()->create(); + $draft = Draft::factory()->create(); // Set the draft_id on the project $sharedProject->draft_id = $draft->id; @@ -248,7 +251,7 @@ public function test_shared_drafts_returns_drafts_from_shared_projects(): void $sharedDrafts = $user->sharedDrafts(); // Should return collection containing drafts from shared projects - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $sharedDrafts); + $this->assertInstanceOf(Collection::class, $sharedDrafts); } public function test_has_project_role_returns_false_for_null_role(): void @@ -307,9 +310,9 @@ public function test_trait_relationship_methods_return_correct_types(): void $user = User::factory()->create(); // Test relationship methods return correct Eloquent relationship types - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->projects()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->activeProjects()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->recentProjects()); + $this->assertInstanceOf(BelongsToMany::class, $user->projects()); + $this->assertInstanceOf(BelongsToMany::class, $user->activeProjects()); + $this->assertInstanceOf(BelongsToMany::class, $user->recentProjects()); } public function test_trait_query_methods_return_correct_types(): void @@ -317,8 +320,8 @@ public function test_trait_query_methods_return_correct_types(): void $user = User::factory()->create(); // Test query methods return Builder or Collection - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->sharedProjects()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $user->sharedDrafts()); + $this->assertInstanceOf(BelongsToMany::class, $user->sharedProjects()); + $this->assertInstanceOf(Collection::class, $user->sharedDrafts()); } public function test_trait_boolean_methods_return_boolean(): void diff --git a/tests/Unit/Models/HasStudiesTraitTest.php b/tests/Unit/Models/HasStudiesTraitTest.php index 135604064..fed0a7787 100644 --- a/tests/Unit/Models/HasStudiesTraitTest.php +++ b/tests/Unit/Models/HasStudiesTraitTest.php @@ -6,6 +6,7 @@ use App\Models\Study; use App\Models\Team; use App\Models\User; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -23,7 +24,7 @@ public function test_studies_relationship_exists(): void { $user = new User; $relationship = $user->studies(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); } public function test_shared_studies_relationship_excludes_creator(): void @@ -32,7 +33,7 @@ public function test_shared_studies_relationship_excludes_creator(): void // Test the relationship exists and is correct type $relationship = $user->sharedStudies(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); // Check the where clause excludes 'creator' role $query = $relationship->getQuery(); @@ -44,7 +45,7 @@ public function test_recent_studies_orders_by_updated_at(): void $user = User::factory()->create(); $relationship = $user->recentStudies(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); // Check ordering $query = $relationship->getQuery(); @@ -218,9 +219,9 @@ public function test_trait_relationship_methods_return_correct_types(): void { $user = new User; - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->studies()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->sharedStudies()); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $user->recentStudies()); + $this->assertInstanceOf(BelongsToMany::class, $user->studies()); + $this->assertInstanceOf(BelongsToMany::class, $user->sharedStudies()); + $this->assertInstanceOf(BelongsToMany::class, $user->recentStudies()); } public function test_trait_boolean_methods_return_boolean(): void diff --git a/tests/Unit/Models/LicenseModelTest.php b/tests/Unit/Models/LicenseModelTest.php index 0b9f35444..1ca12e3af 100644 --- a/tests/Unit/Models/LicenseModelTest.php +++ b/tests/Unit/Models/LicenseModelTest.php @@ -3,6 +3,7 @@ namespace Tests\Unit\Models; use App\Models\License; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -13,19 +14,19 @@ class LicenseModelTest extends TestCase public function test_it_has_many_projects(): void { $license = License::factory()->create(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $license->projects()); + $this->assertInstanceOf(HasMany::class, $license->projects()); } public function test_it_has_many_studies(): void { $license = License::factory()->create(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $license->studies()); + $this->assertInstanceOf(HasMany::class, $license->studies()); } public function test_it_has_many_datasets(): void { $license = License::factory()->create(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $license->datasets()); + $this->assertInstanceOf(HasMany::class, $license->datasets()); } public function test_it_has_correct_fillable_attributes(): void diff --git a/tests/Unit/Models/MoleculeModelTest.php b/tests/Unit/Models/MoleculeModelTest.php index 2c6b6c239..f465aff4d 100644 --- a/tests/Unit/Models/MoleculeModelTest.php +++ b/tests/Unit/Models/MoleculeModelTest.php @@ -5,6 +5,9 @@ use App\Models\Molecule; use App\Models\Sample; use App\Models\Study; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Testing\RefreshDatabase; use PHPUnit\Framework\Attributes\Test; use Tests\TestCase; @@ -19,7 +22,7 @@ public function test_it_belongs_to_many_samples() // Test the relationship exists and is correct type $relationship = $molecule->samples(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); } public function test_samples_relationship_includes_pivot_data() @@ -28,7 +31,7 @@ public function test_samples_relationship_includes_pivot_data() // Test pivot relationship configuration $relationship = $molecule->samples(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); // Test pivot columns are configured $pivotColumns = $relationship->getPivotColumns(); @@ -106,7 +109,7 @@ public function test_samples_relationship_is_many_to_many() $molecule = new Molecule; $relationship = $molecule->samples(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); } public function test_all_required_fields_are_fillable() @@ -215,7 +218,7 @@ public function test_studies_method_calls_sample_load_method() $molecule = new Molecule; // Create a mock for the samples collection that has a load method - $samplesCollection = $this->getMockBuilder(\Illuminate\Database\Eloquent\Collection::class) + $samplesCollection = $this->getMockBuilder(Collection::class) ->onlyMethods(['load']) ->getMock(); @@ -256,7 +259,7 @@ public function test_studies_method_calls_sample_load_method() $studiesQuery = $molecule->studies(); // Should return Eloquent query builder - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $studiesQuery); + $this->assertInstanceOf(Builder::class, $studiesQuery); } #[Test] @@ -288,7 +291,7 @@ public function test_studies_method_processes_foreach_loop_correctly() $method = $reflection->getMethod('studies'); // We need to mock the samples property to return our collection with load method - $mockSamplesCollection = $this->getMockBuilder(\Illuminate\Database\Eloquent\Collection::class) + $mockSamplesCollection = $this->getMockBuilder(Collection::class) ->onlyMethods(['load']) ->getMock(); @@ -311,7 +314,7 @@ public function test_studies_method_processes_foreach_loop_correctly() $result = $molecule->studies(); // Should return a query builder - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result); + $this->assertInstanceOf(Builder::class, $result); } #[Test] @@ -329,7 +332,7 @@ public function test_studies_method_array_push_functionality() $samplesCollection = collect([$sample]); - $mockSamplesCollection = $this->getMockBuilder(\Illuminate\Database\Eloquent\Collection::class) + $mockSamplesCollection = $this->getMockBuilder(Collection::class) ->onlyMethods(['load']) ->getMock(); @@ -351,6 +354,6 @@ public function test_studies_method_array_push_functionality() $result = $molecule->studies(); // Should return a query builder that will search for study ID 42 - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result); + $this->assertInstanceOf(Builder::class, $result); } } diff --git a/tests/Unit/Models/NMRiumModelTest.php b/tests/Unit/Models/NMRiumModelTest.php index 1c3f70d89..06fef2163 100644 --- a/tests/Unit/Models/NMRiumModelTest.php +++ b/tests/Unit/Models/NMRiumModelTest.php @@ -6,6 +6,8 @@ use App\Models\NMRium; use App\Models\Study; use App\Models\User; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -133,10 +135,10 @@ public function test_relationship_types_are_correct(): void $nmrium = new NMRium; // Test polymorphic relationship - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\MorphTo::class, $nmrium->nmriumable()); + $this->assertInstanceOf(MorphTo::class, $nmrium->nmriumable()); // Test user relationship (even though there's no user_id column in DB - method exists) - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $nmrium->user()); + $this->assertInstanceOf(BelongsTo::class, $nmrium->user()); } public function test_complex_nmrium_data_storage(): void diff --git a/tests/Unit/Models/ProjectInvitationModelTest.php b/tests/Unit/Models/ProjectInvitationModelTest.php index 69c56e330..df9397813 100644 --- a/tests/Unit/Models/ProjectInvitationModelTest.php +++ b/tests/Unit/Models/ProjectInvitationModelTest.php @@ -4,6 +4,7 @@ use App\Models\Project; use App\Models\ProjectInvitation; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -66,7 +67,7 @@ public function test_project_relationship_is_belongs_to() $invitation = new ProjectInvitation; $relationship = $invitation->project(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $relationship); + $this->assertInstanceOf(BelongsTo::class, $relationship); } public function test_all_required_fields_are_fillable() diff --git a/tests/Unit/Models/SampleModelTest.php b/tests/Unit/Models/SampleModelTest.php index 2a39e8acf..19efc4eca 100644 --- a/tests/Unit/Models/SampleModelTest.php +++ b/tests/Unit/Models/SampleModelTest.php @@ -4,6 +4,9 @@ use App\Models\Sample; use App\Models\Study; +use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -26,10 +29,10 @@ public function test_it_belongs_to_many_molecules() // Test the relationship method exists and is correct type $relationship = $sample->molecules(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); // Test initial empty collection - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $sample->molecules); + $this->assertInstanceOf(Collection::class, $sample->molecules); $this->assertCount(0, $sample->molecules); } @@ -39,7 +42,7 @@ public function test_molecules_relationship_includes_pivot_data() // Test pivot relationship configuration $relationship = $sample->molecules(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); // Test pivot columns are configured $pivotColumns = $relationship->getPivotColumns(); @@ -105,7 +108,7 @@ public function test_study_relationship_is_belongs_to() $sample = Sample::factory()->create(); $relationship = $sample->study(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsTo::class, $relationship); + $this->assertInstanceOf(BelongsTo::class, $relationship); } public function test_molecules_relationship_is_many_to_many() @@ -113,7 +116,7 @@ public function test_molecules_relationship_is_many_to_many() $sample = Sample::factory()->create(); $relationship = $sample->molecules(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); } public function test_all_required_fields_are_fillable() @@ -145,7 +148,7 @@ public function test_sample_can_have_multiple_molecules_with_different_compositi // Test that molecules relationship supports pivot data $relationship = $sample->molecules(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\BelongsToMany::class, $relationship); + $this->assertInstanceOf(BelongsToMany::class, $relationship); // Check that withPivot includes percentage_composition $pivotColumns = $relationship->getPivotColumns(); diff --git a/tests/Unit/Models/Schemas/BioschemasModelTest.php b/tests/Unit/Models/Schemas/BioschemasModelTest.php index 328b4e039..45f48b4dc 100644 --- a/tests/Unit/Models/Schemas/BioschemasModelTest.php +++ b/tests/Unit/Models/Schemas/BioschemasModelTest.php @@ -4,6 +4,8 @@ use App\Models\Schemas\Bioschemas; use App\Models\Schemas\Study; +use Spatie\SchemaOrg\BaseType; +use Spatie\SchemaOrg\Schema; use Tests\TestCase; class BioschemasModelTest extends TestCase @@ -170,12 +172,12 @@ public function test_study_schema_returns_json_ld_context(): void public function test_bioschemas_extends_spatie_schema(): void { - $this->assertTrue(is_subclass_of(Bioschemas::class, \Spatie\SchemaOrg\Schema::class)); + $this->assertTrue(is_subclass_of(Bioschemas::class, Schema::class)); } public function test_study_extends_spatie_base_type(): void { - $this->assertTrue(is_subclass_of(Study::class, \Spatie\SchemaOrg\BaseType::class)); + $this->assertTrue(is_subclass_of(Study::class, BaseType::class)); } public function test_bioschemas_can_create_multiple_study_instances(): void diff --git a/tests/Unit/Models/StudyInvitationModelTest.php b/tests/Unit/Models/StudyInvitationModelTest.php index 40f4ca314..b056f7802 100644 --- a/tests/Unit/Models/StudyInvitationModelTest.php +++ b/tests/Unit/Models/StudyInvitationModelTest.php @@ -5,6 +5,7 @@ use App\Models\Study; use App\Models\StudyInvitation; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Carbon; use Tests\TestCase; class StudyInvitationModelTest extends TestCase @@ -199,8 +200,8 @@ public function test_it_has_timestamps(): void $this->assertNotNull($invitation->created_at); $this->assertNotNull($invitation->updated_at); - $this->assertInstanceOf(\Illuminate\Support\Carbon::class, $invitation->created_at); - $this->assertInstanceOf(\Illuminate\Support\Carbon::class, $invitation->updated_at); + $this->assertInstanceOf(Carbon::class, $invitation->created_at); + $this->assertInstanceOf(Carbon::class, $invitation->updated_at); } public function test_it_can_be_updated(): void diff --git a/tests/Unit/Models/StudyModelTest.php b/tests/Unit/Models/StudyModelTest.php index c4c21a3e0..caa16665c 100644 --- a/tests/Unit/Models/StudyModelTest.php +++ b/tests/Unit/Models/StudyModelTest.php @@ -15,6 +15,8 @@ use App\Models\User; use App\Models\Validation; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\MorphOne; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Storage; @@ -621,7 +623,7 @@ public function test_it_has_nmrium_relationship(): void // Test that the relationship exists and returns correct type $relationship = $study->nmrium(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\MorphOne::class, $relationship); + $this->assertInstanceOf(MorphOne::class, $relationship); // Test the relationship configuration $this->assertEquals(NMRium::class, $relationship->getRelated()::class); @@ -679,7 +681,7 @@ public function test_molecules_method_returns_sample_molecules(): void // Test the relationship chain exists $sampleRelation = $study->sample(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasOne::class, $sampleRelation); + $this->assertInstanceOf(HasOne::class, $sampleRelation); // Test that the molecules method exists and can be called without throwing an error // The actual implementation delegates to sample()->molecules() but we just need to cover the line diff --git a/tests/Unit/Models/TeamModelTest.php b/tests/Unit/Models/TeamModelTest.php index bd141fb28..0e85c0766 100644 --- a/tests/Unit/Models/TeamModelTest.php +++ b/tests/Unit/Models/TeamModelTest.php @@ -5,7 +5,11 @@ use App\Models\Project; use App\Models\Team; use App\Models\User; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Foundation\Testing\RefreshDatabase; +use Laravel\Jetstream\Events\TeamCreated; +use Laravel\Jetstream\Events\TeamDeleted; +use Laravel\Jetstream\Events\TeamUpdated; use Laravel\Jetstream\Team as JetstreamTeam; use Tests\TestCase; @@ -141,14 +145,14 @@ public function test_projects_relationship_is_has_many(): void { $team = Team::factory()->create(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $team->projects()); + $this->assertInstanceOf(HasMany::class, $team->projects()); } public function test_active_projects_relationship_is_has_many(): void { $team = Team::factory()->create(); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Relations\HasMany::class, $team->activeProjects()); + $this->assertInstanceOf(HasMany::class, $team->activeProjects()); } public function test_factory_creates_unique_team_names(): void @@ -238,9 +242,9 @@ public function test_it_has_jetstream_events_configured(): void $events = $property->getValue($team); $expectedEvents = [ - 'created' => \Laravel\Jetstream\Events\TeamCreated::class, - 'updated' => \Laravel\Jetstream\Events\TeamUpdated::class, - 'deleted' => \Laravel\Jetstream\Events\TeamDeleted::class, + 'created' => TeamCreated::class, + 'updated' => TeamUpdated::class, + 'deleted' => TeamDeleted::class, ]; $this->assertEquals($expectedEvents, $events); diff --git a/tests/Unit/Models/UserModelTest.php b/tests/Unit/Models/UserModelTest.php index 201bfc6d5..56bcc3a7e 100644 --- a/tests/Unit/Models/UserModelTest.php +++ b/tests/Unit/Models/UserModelTest.php @@ -10,7 +10,9 @@ use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Notifications\DatabaseNotification; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Notification; +use Illuminate\Support\Str; use Spatie\Permission\Models\Role; use Tests\TestCase; @@ -239,7 +241,7 @@ public function test_it_casts_email_verified_at_as_datetime(): void 'email_verified_at' => '2023-01-01 12:00:00', ]); - $this->assertInstanceOf(\Illuminate\Support\Carbon::class, $user->email_verified_at); + $this->assertInstanceOf(Carbon::class, $user->email_verified_at); } public function test_it_has_teams_when_using_jetstream(): void @@ -394,7 +396,7 @@ public function test_it_can_mark_notification_as_read(): void // Create a fake notification manually in the database $notification = DatabaseNotification::create([ - 'id' => \Illuminate\Support\Str::uuid(), + 'id' => Str::uuid(), 'type' => 'App\\Notifications\\TestNotification', 'notifiable_type' => User::class, 'notifiable_id' => $user->id, diff --git a/tests/Unit/Models/ValidationModelTest.php b/tests/Unit/Models/ValidationModelTest.php index 143bc6b14..7f86c470d 100644 --- a/tests/Unit/Models/ValidationModelTest.php +++ b/tests/Unit/Models/ValidationModelTest.php @@ -3,9 +3,12 @@ namespace Tests\Unit\Models; use App\Models\Dataset; +use App\Models\FileSystemObject; use App\Models\Project; +use App\Models\Sample; use App\Models\Study; use App\Models\Validation; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; @@ -32,7 +35,7 @@ public function test_it_has_many_studies() $study1 = Study::factory()->create(['validation_id' => $validation->id]); $study2 = Study::factory()->create(['validation_id' => $validation->id]); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $validation->studies); + $this->assertInstanceOf(Collection::class, $validation->studies); $this->assertCount(2, $validation->studies); $this->assertTrue($validation->studies->contains($study1)); $this->assertTrue($validation->studies->contains($study2)); @@ -46,7 +49,7 @@ public function test_it_has_many_datasets() $dataset1 = Dataset::factory()->create(['validation_id' => $validation->id]); $dataset2 = Dataset::factory()->create(['validation_id' => $validation->id]); - $this->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $validation->datasets); + $this->assertInstanceOf(Collection::class, $validation->datasets); $this->assertCount(2, $validation->datasets); $this->assertTrue($validation->datasets->contains($dataset1)); $this->assertTrue($validation->datasets->contains($dataset2)); @@ -515,7 +518,7 @@ public function test_process_handles_studies_validation_success() 'name' => 'Valid Study', ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); config(['validations.default' => 'v1']); config(['validations.v1.project' => ['title' => 'required|string']]); @@ -549,7 +552,7 @@ public function test_process_handles_study_validation_failures() 'name' => '', // Invalid empty name ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); config(['validations.default' => 'v1']); config(['validations.v1.project' => ['title' => 'required|string']]); @@ -582,7 +585,7 @@ public function test_process_handles_dataset_with_fs_object() 'validation_id' => $validation->id, 'project_id' => $project->id, ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); $dataset = Dataset::factory()->create([ 'validation_id' => $validation->id, @@ -590,7 +593,7 @@ public function test_process_handles_dataset_with_fs_object() ]); // Create fsObject with instrument_type - $fsObject = \App\Models\FileSystemObject::create([ + $fsObject = FileSystemObject::create([ 'name' => 'test-file.txt', 'slug' => 'test-file', 'key' => 'test-key', @@ -628,7 +631,7 @@ public function test_process_handles_dataset_without_fs_object_but_with_children 'validation_id' => $validation->id, 'project_id' => $project->id, ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); $dataset = Dataset::factory()->create([ 'validation_id' => $validation->id, @@ -636,7 +639,7 @@ public function test_process_handles_dataset_without_fs_object_but_with_children ]); // Create parent fsObject without instrument_type - $parentFsObject = \App\Models\FileSystemObject::create([ + $parentFsObject = FileSystemObject::create([ 'name' => 'parent-file.txt', 'slug' => 'parent-file', 'key' => 'parent-key', @@ -646,7 +649,7 @@ public function test_process_handles_dataset_without_fs_object_but_with_children ]); // Create child fsObject with instrument_type - $childFsObject = \App\Models\FileSystemObject::create([ + $childFsObject = FileSystemObject::create([ 'name' => 'child-file.txt', 'slug' => 'child-file', 'key' => 'child-key', @@ -677,7 +680,7 @@ public function test_process_handles_dataset_validation_failures() 'validation_id' => $validation->id, 'project_id' => $project->id, ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); $dataset = Dataset::factory()->create([ 'validation_id' => $validation->id, @@ -718,7 +721,7 @@ public function test_process_handles_dataset_validation_success() 'validation_id' => $validation->id, 'project_id' => $project->id, ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); $dataset = Dataset::factory()->create([ 'validation_id' => $validation->id, @@ -727,7 +730,7 @@ public function test_process_handles_dataset_validation_success() ]); // Create fsObject with all required data - $fsObject = \App\Models\FileSystemObject::create([ + $fsObject = FileSystemObject::create([ 'name' => 'valid-file.txt', 'slug' => 'valid-file', 'key' => 'valid-key', @@ -886,7 +889,7 @@ public function test_process_method_with_complete_project_structure() 'name' => 'Complete Study', ]); - $sample = \App\Models\Sample::factory()->create(['study_id' => $study->id]); + $sample = Sample::factory()->create(['study_id' => $study->id]); $dataset = Dataset::factory()->create([ 'validation_id' => $validation->id, @@ -937,7 +940,7 @@ public function test_process_handles_validation_rules_success_paths(): void 'project_id' => $project->id, ]); - $sample = \App\Models\Sample::factory()->create([ + $sample = Sample::factory()->create([ 'study_id' => $study->id, ]); From 4768ca4e97dc4eeb9d6e1ef290e8e93f1371d747 Mon Sep 17 00:00:00 2001 From: Nisha Sharma Date: Wed, 1 Apr 2026 12:33:48 +0200 Subject: [PATCH 2/2] chore: update package-lock.json and yarn.lock --- package-lock.json | 40 ++++++++++++++++++++-------------------- yarn.lock | 30 +++++++++++++++--------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 938484286..a7008846a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,10 @@ { - "name": "html", + "name": "nmrxiv", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "html", + "name": "nmrxiv", "dependencies": { "@headlessui/vue": "^1.6.2", "@heroicons/vue": "^2.0.11", @@ -2381,9 +2381,9 @@ "license": "ISC" }, "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz", + "integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==", "dev": true, "license": "MIT", "dependencies": { @@ -5366,9 +5366,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "license": "MIT", "engines": { "node": ">=8.6" @@ -6307,9 +6307,9 @@ } }, "node_modules/sucrase/node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz", + "integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==", "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -6661,9 +6661,9 @@ } }, "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", "engines": { @@ -7477,9 +7477,9 @@ } }, "node_modules/vite/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", "engines": { @@ -8582,9 +8582,9 @@ } }, "node_modules/yaml": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", - "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", + "integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==", "license": "ISC", "bin": { "yaml": "bin.mjs" diff --git a/yarn.lock b/yarn.lock index 4f37aeaca..005d25870 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1411,17 +1411,17 @@ boolbase@^1.0.0: integrity sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww== brace-expansion@^1.1.7: - version "1.1.12" - resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz" - integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== + version "1.1.13" + resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz" + integrity sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" brace-expansion@^2.0.2: - version "2.0.2" - resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz" - integrity sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ== + version "2.0.3" + resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz" + integrity sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA== dependencies: balanced-match "^1.0.0" @@ -3027,14 +3027,14 @@ picocolors@^1.0.0, picocolors@^1.1.1: integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + version "2.3.2" + resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz" + integrity sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA== "picomatch@^3 || ^4", picomatch@^4.0.2: - version "4.0.3" - resolved "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz" - integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q== + version "4.0.4" + resolved "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz" + integrity sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A== pidtree@^0.6.0: version "0.6.0" @@ -4100,9 +4100,9 @@ y18n@^5.0.5: integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== yaml@^2.3.4, yaml@^2.4.2, yaml@^2.8.1: - version "2.8.2" - resolved "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz" - integrity sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A== + version "2.8.3" + resolved "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz" + integrity sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg== yargs-parser@^21.1.1: version "21.1.1"