Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yungifez committed Aug 10, 2023
1 parent c8f9a97 commit 4984a0b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
8 changes: 4 additions & 4 deletions app/Http/Middleware/CreateCurrentAcademicYearRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
]);
}

Expand Down
53 changes: 25 additions & 28 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="DB_DATABASE" value="testing"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<coverage/>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="DB_DATABASE" value="testing"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
<source>
<include>
<directory suffix=".php">./app</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
Expand Down

0 comments on commit 4984a0b

Please sign in to comment.