From 4984a0b02fa0d1ca883e6a1aa3800641019bffa2 Mon Sep 17 00:00:00 2001 From: Marvellous Date: Thu, 10 Aug 2023 12:02:59 +0100 Subject: [PATCH] Fix failing tests --- .../CreateCurrentAcademicYearRecord.php | 8 +-- phpunit.xml | 53 +++++++++---------- routes/web.php | 4 +- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/app/Http/Middleware/CreateCurrentAcademicYearRecord.php b/app/Http/Middleware/CreateCurrentAcademicYearRecord.php index 29b1cb05..a3ba96a3 100644 --- a/app/Http/Middleware/CreateCurrentAcademicYearRecord.php +++ b/app/Http/Middleware/CreateCurrentAcademicYearRecord.php @@ -11,16 +11,16 @@ class CreateCurrentAcademicYearRecord /** * Handle an incoming request. * - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ public function handle(Request $request, Closure $next): Response { - if(auth()->user()?->studentRecord && !auth()->user()?->studentRecord?->academicYears()->find(auth()->user()->school->academic_year_id)){ + if(auth()?->user()?->studentRecord != null && !auth()->user()?->studentRecord?->academicYears()->find(auth()->user()->school->academic_year_id)){ auth()->user()->studentRecord->academicYears()->syncWithoutDetaching([ auth()->user()->school->academicYear->id => [ 'my_class_id' => auth()->user()->studentRecord->my_class_id, - 'section_id' => auth()->user()->studentRecord->section_id, - ] + 'section_id' => auth()->user()->studentRecord->section_id, + ], ]); } diff --git a/phpunit.xml b/phpunit.xml index 9d487a97..543dab8c 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,30 +1,27 @@ - - - - ./tests/Unit - - - ./tests/Feature - - - - - ./app - - - - - - - - - - - - + + + + ./tests/Unit + + + ./tests/Feature + + + + + + + + + + + + + + + + ./app + + diff --git a/routes/web.php b/routes/web.php index 448dbed5..ba701dbf 100755 --- a/routes/web.php +++ b/routes/web.php @@ -39,7 +39,7 @@ Route::post('schools/set-school', ['App\Http\Controllers\SchoolController', 'setSchool'])->name('schools.setSchool'); //super admin must have school id set - Route::middleware(['App\Http\Middleware\EnsureSuperAdminHasSchoolId', 'App\Http\Middleware\CreateCurrentAcademicYearRecord'])->group(function () { + Route::middleware(['App\Http\Middleware\EnsureSuperAdminHasSchoolId', ])->group(function () { //dashboard route Route::get('/', function () { return view('dashboard'); @@ -54,7 +54,7 @@ //sections routes Route::resource('sections', SectionController::class); - Route::middleware(['App\Http\Middleware\EnsureAcademicYearIsSet'])->group(function () { + Route::middleware(['App\Http\Middleware\EnsureAcademicYearIsSet', 'App\Http\Middleware\CreateCurrentAcademicYearRecord'])->group(function () { Route::get('account-applications/rejected-applications', ['App\Http\Controllers\AccountApplicationController', 'rejectedApplicationsView'])->name('account-applications.rejected-applications'); //account application routes. We need the applicant instead of the record