Add lesson booking registration flow (offering, questions, policies)
CI / Coding Standards (pull_request) Successful in 1m51s
CI / PHPStan (pull_request) Successful in 2m17s
CI / Tests (PHP 8.1) (pull_request) Successful in 2m24s
CI / No Debug Code (pull_request) Successful in 2s
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / Tests (PHP 8.3) (pull_request) Successful in 47s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / Coding Standards (pull_request) Successful in 1m51s
CI / PHPStan (pull_request) Successful in 2m17s
CI / Tests (PHP 8.1) (pull_request) Successful in 2m24s
CI / No Debug Code (pull_request) Successful in 2s
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / Tests (PHP 8.3) (pull_request) Successful in 47s
CI / Build Plugin Zip (pull_request) Has been skipped
Implements #3: students register for a private lesson by picking a slot, answering the offering's intake questions, and accepting booking-scoped policies. Payment is a clean seam for #7 (lessons land pending; payment_id null; instructor confirms via PATCH /bookings/{id}/status). - Schema: us_lessons += offering_id, recurrence, series_id, payment_id. - Lesson: new fields + recurrence constants. - BookingRepository::insertSeries() builds a weekly series sharing a series_id; AvailabilityRepository::findUnbookedInGroup() reserves a group. - RegistrationGate (src/Registration/): validate + record intake answers and booking-scoped policy acceptances. Reused by group enrolment (#4). - BookingEndpoint::book(): offering_id, recurrence, answers, accepted_policy_version_ids; single or weekly; records answers/acceptances (type lesson). - GET /policies?scope=booking filter. - Front-end booking.js: slot -> questions + policies -> submit. - Wiring: RegistrationGate built in Plugin, passed via RestRegistrar. - Test-only WP_Error stub in tests/bootstrap.php for gate testing. Refs #3 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,41 +28,52 @@ class LessonTest extends TestCase
|
||||
$lesson = new Lesson(slotId: 1, studentId: 2, instructorId: 3);
|
||||
|
||||
self::assertSame(Lesson::STATUS_PENDING, $lesson->status);
|
||||
self::assertNull($lesson->offeringId);
|
||||
self::assertSame(Lesson::RECURRENCE_SINGLE, $lesson->recurrence);
|
||||
self::assertNull($lesson->seriesId);
|
||||
self::assertNull($lesson->paymentId);
|
||||
self::assertNull($lesson->notes);
|
||||
self::assertNull($lesson->id);
|
||||
}
|
||||
|
||||
public function testRecurrenceConstants(): void
|
||||
{
|
||||
self::assertContains(Lesson::RECURRENCE_SINGLE, Lesson::VALID_RECURRENCES);
|
||||
self::assertContains(Lesson::RECURRENCE_WEEKLY, Lesson::VALID_RECURRENCES);
|
||||
}
|
||||
|
||||
public function testFromRowMapsCorrectly(): void
|
||||
{
|
||||
$row = (object) [
|
||||
'id' => '99',
|
||||
'slot_id' => '10',
|
||||
'offering_id' => '7',
|
||||
'student_id' => '20',
|
||||
'instructor_id' => '30',
|
||||
'recurrence' => Lesson::RECURRENCE_WEEKLY,
|
||||
'series_id' => '99',
|
||||
'status' => 'confirmed',
|
||||
'payment_id' => null,
|
||||
'notes' => 'Bring your guitar.',
|
||||
];
|
||||
|
||||
$lesson = Lesson::fromRow($row);
|
||||
|
||||
self::assertSame(99, $lesson->id);
|
||||
self::assertSame(10, $lesson->slotId);
|
||||
self::assertSame(20, $lesson->studentId);
|
||||
self::assertSame(30, $lesson->instructorId);
|
||||
self::assertSame(7, $lesson->offeringId);
|
||||
self::assertSame(Lesson::RECURRENCE_WEEKLY, $lesson->recurrence);
|
||||
self::assertSame(99, $lesson->seriesId);
|
||||
self::assertNull($lesson->paymentId);
|
||||
self::assertSame('confirmed', $lesson->status);
|
||||
self::assertSame('Bring your guitar.', $lesson->notes);
|
||||
}
|
||||
|
||||
public function testToArrayContainsExpectedKeys(): void
|
||||
{
|
||||
$lesson = new Lesson(1, 2, 3, Lesson::STATUS_PENDING, 'Note', 5);
|
||||
$lesson = new Lesson(slotId: 1, studentId: 2, instructorId: 3, notes: 'Note', id: 5);
|
||||
$arr = $lesson->toArray();
|
||||
|
||||
self::assertArrayHasKey('id', $arr);
|
||||
self::assertArrayHasKey('slot_id', $arr);
|
||||
self::assertArrayHasKey('student_id', $arr);
|
||||
self::assertArrayHasKey('instructor_id', $arr);
|
||||
self::assertArrayHasKey('status', $arr);
|
||||
self::assertArrayHasKey('notes', $arr);
|
||||
foreach (['id', 'slot_id', 'offering_id', 'student_id', 'instructor_id', 'recurrence', 'series_id', 'status', 'payment_id', 'notes'] as $key) {
|
||||
self::assertArrayHasKey($key, $arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user