From 5f5afe97ad30894410c6875d935e824cb64e2f4c Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 Aug 2026 22:14:05 -0400 Subject: [PATCH] fix test issues --- app/Services/EnrollmentTransitionService.php | 6 +++++- .../app/Services/EnrollmentTransitionServiceTest.php | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Services/EnrollmentTransitionService.php b/app/Services/EnrollmentTransitionService.php index 6ad8c1a..0dd6cbc 100644 --- a/app/Services/EnrollmentTransitionService.php +++ b/app/Services/EnrollmentTransitionService.php @@ -2348,13 +2348,17 @@ final class EnrollmentTransitionService $overridableFailed = array_values(array_diff($failedCodes, self::NON_OVERRIDABLE_RULE_CODES)); $recordedCodes = json_decode((string) ($exception['bypassed_rule_codes_json'] ?? ''), true); $recordedCodes = is_array($recordedCodes) ? array_values(array_filter(array_map('strval', $recordedCodes))) : []; + $applicableCodes = array_values(array_intersect($overridableFailed, $recordedCodes)); + if ($applicableCodes === []) { + return; + } $evaluation['admin_exception'] = [ 'id' => (int) $exception['id'], 'reason_code' => (string) ($exception['reason_code'] ?? ''), 'source_school_year' => $sourceSchoolYear, 'status' => (string) ($exception['status'] ?? ''), - 'bypassed_rule_codes' => $overridableFailed !== [] ? $overridableFailed : $recordedCodes, + 'bypassed_rule_codes' => $applicableCodes, ]; $evaluation['decision'] = self::DECISION_EXCEPTION_ELIGIBLE; $evaluation['parent_enrollment_allowed'] = true; diff --git a/tests/app/Services/EnrollmentTransitionServiceTest.php b/tests/app/Services/EnrollmentTransitionServiceTest.php index 3c7a095..aebf0a2 100644 --- a/tests/app/Services/EnrollmentTransitionServiceTest.php +++ b/tests/app/Services/EnrollmentTransitionServiceTest.php @@ -87,6 +87,11 @@ final class EnrollmentTransitionServiceTest extends TestCase { return $this->row; } + + public function getResultArray(): array + { + return $this->row === null ? [] : [$this->row]; + } }); return $builder; @@ -303,6 +308,7 @@ final class EnrollmentTransitionServiceTest extends TestCase $builder->method('groupStart')->willReturnSelf(); $builder->method('orWhere')->willReturnSelf(); $builder->method('groupEnd')->willReturnSelf(); + $builder->method('whereIn')->willReturnSelf(); $builder->method('orderBy')->willReturnSelf(); $builder->method('limit')->willReturnSelf(); $builder->method('get')->willReturn(new class { @@ -314,6 +320,11 @@ final class EnrollmentTransitionServiceTest extends TestCase 'bypassed_rule_codes_json' => '[]', ]; } + + public function getResultArray(): array + { + return [$this->getRowArray()]; + } }); $db = $this->createMock(BaseConnection::class);