status); self::assertNull($enrollment->paymentId); self::assertNull($enrollment->id); } public function testStatusConstants(): void { self::assertContains(Enrollment::STATUS_ACTIVE, Enrollment::VALID_STATUSES); self::assertContains(Enrollment::STATUS_CANCELLED, Enrollment::VALID_STATUSES); self::assertContains(Enrollment::STATUS_COMPLETED, Enrollment::VALID_STATUSES); } public function testFromRowMapsCorrectly(): void { $enrollment = Enrollment::fromRow((object) [ 'id' => '12', 'offering_id' => '7', 'student_id' => '5', 'instructor_id' => '3', 'status' => Enrollment::STATUS_ACTIVE, 'payment_id' => null, ]); self::assertSame(12, $enrollment->id); self::assertSame(7, $enrollment->offeringId); self::assertSame(5, $enrollment->studentId); self::assertNull($enrollment->paymentId); } public function testToArrayContainsExpectedKeys(): void { $arr = (new Enrollment(7, 5, 3, id: 12))->toArray(); foreach (['id', 'offering_id', 'student_id', 'instructor_id', 'status', 'payment_id', 'enrolled_by'] as $key) { self::assertArrayHasKey($key, $arr); } } public function testAnEnrolmentIsItsOwnIntakeRegistration(): void { $enrollment = new Enrollment(7, 5, 3, id: 12); self::assertSame(Answer::REG_ENROLLMENT, $enrollment->intakeRegistrationType()); // No series anchor to follow: a term of classes is one enrolment. self::assertSame(12, $enrollment->intakeRegistrationId()); self::assertSame(7, $enrollment->intakeOfferingId()); self::assertSame(5, $enrollment->intakeStudentId()); } public function testOnlyAStudioMadeEnrolmentIsStaffRegistered(): void { self::assertFalse((new Enrollment(7, 5, 3, id: 12))->isStaffRegistered()); self::assertTrue((new Enrollment(7, 5, 3, enrolledBy: 9, id: 12))->isStaffRegistered()); } }