Never drop an enrolled class from upcoming lessons; delete a guardian's children with them; pin the panel's line spacing
CI / Tests (PHP 8.2) (pull_request) Successful in 58s
CI / PHPStan (pull_request) Successful in 2m53s
CI / Coding Standards (pull_request) Successful in 2m58s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m47s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 1m1s
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.2) (pull_request) Successful in 58s
CI / PHPStan (pull_request) Successful in 2m53s
CI / Coding Standards (pull_request) Successful in 2m58s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m47s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 1m1s
CI / No Debug Code (pull_request) Successful in 3s
Three fixes from testing the branch. A group class was only listed when its schedule resolved to exact datetimes, which needs a class time *and* a duration — both optional on the offering form, and the schedule note exists precisely so a studio can write "Tuesdays 4:00pm" instead. A class configured that way vanished from the list, which is the one thing this feature must never do. So Offering::sessionStarts() splits "when does it meet" from "how long does it run" (sessionWindows() is that plus the duration, unchanged), and SessionSchedule degrades instead of disappearing: dated rows with an open end when there is no duration, and a single row carrying Offering::scheduleLabel() when there is no time to derive dates from. Only a class whose last day has passed drops out. Deleting a guardian now deletes the children linked to them, releasing each one's lessons and enrolments first. A child account is login-less and exists only so the guardian has somebody to book for; without the guardian nobody can reach it, book for it, or be billed for it, so it was left stranded on the roster still holding slots. A `handled` set makes the re-entrant delete_user each child deletion fires a no-op, and stops a circular link recursing. The upcoming panel never stated its own line-height, so a theme setting line-height: 0 above it — the usual icon-font reset — was inherited straight through. Below 1 that produces both reported symptoms at once: stacked lines overlap, and the status pill's background is shorter than the text in it. Pinned at the same id-level specificity as the rest. Tests: composer test (863), composer lint, composer cs all pass. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -11,6 +11,9 @@ use Unsupervised\Schedular\Booking\BookingRepository;
|
||||
use Unsupervised\Schedular\Booking\Lesson;
|
||||
use Unsupervised\Schedular\GroupClass\Enrollment;
|
||||
use Unsupervised\Schedular\GroupClass\EnrollmentRepository;
|
||||
use Unsupervised\Schedular\Guardian\GuardianLink;
|
||||
use Unsupervised\Schedular\Guardian\GuardianRepository;
|
||||
use Unsupervised\Schedular\Guardian\GuardianService;
|
||||
use Unsupervised\Schedular\Payment\PaymentService;
|
||||
use Unsupervised\Schedular\Tests\Unit\TestCase;
|
||||
|
||||
@@ -20,6 +23,8 @@ class DeletedUserCleanupTest extends TestCase
|
||||
private AvailabilityRepository&Mockery\MockInterface $availability;
|
||||
private EnrollmentRepository&Mockery\MockInterface $enrollments;
|
||||
private PaymentService&Mockery\MockInterface $payments;
|
||||
private GuardianRepository&Mockery\MockInterface $links;
|
||||
private GuardianService&Mockery\MockInterface $guardians;
|
||||
private DeletedUserCleanup $cleanup;
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -30,12 +35,19 @@ class DeletedUserCleanupTest extends TestCase
|
||||
$this->availability = Mockery::mock(AvailabilityRepository::class);
|
||||
$this->enrollments = Mockery::mock(EnrollmentRepository::class);
|
||||
$this->payments = Mockery::mock(PaymentService::class);
|
||||
$this->links = Mockery::mock(GuardianRepository::class);
|
||||
$this->guardians = Mockery::mock(GuardianService::class);
|
||||
|
||||
// Most accounts have nobody linked to them; the guardian tests say so.
|
||||
$this->links->shouldReceive('findByGuardian')->andReturn([])->byDefault();
|
||||
|
||||
$this->cleanup = new DeletedUserCleanup(
|
||||
$this->bookings,
|
||||
$this->availability,
|
||||
$this->enrollments,
|
||||
$this->payments
|
||||
$this->payments,
|
||||
$this->links,
|
||||
$this->guardians
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,4 +146,89 @@ class DeletedUserCleanupTest extends TestCase
|
||||
|
||||
$this->cleanup->releaseBookings(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* A child account is login-less and exists only so its guardian has somebody
|
||||
* to book for. Without the guardian nobody can reach it, book for it, or be
|
||||
* billed for it — so it goes too, and what it was holding goes back.
|
||||
*/
|
||||
public function testDeletingAGuardianReleasesAndDeletesEachChild(): void
|
||||
{
|
||||
$this->bookings->shouldReceive('findUpcomingForStudent')->with(5)->andReturn([]);
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([]);
|
||||
|
||||
$this->links->shouldReceive('findByGuardian')->with(5)->andReturn([
|
||||
new GuardianLink(guardianId: 5, studentId: 42, id: 1),
|
||||
new GuardianLink(guardianId: 5, studentId: 43, id: 2),
|
||||
]);
|
||||
|
||||
$this->bookings->shouldReceive('findUpcomingForStudent')->with(42)->andReturn([
|
||||
new Lesson(slotId: 7, studentId: 42, instructorId: 3, status: Lesson::STATUS_CONFIRMED, paymentId: 40, id: 12),
|
||||
]);
|
||||
$this->bookings->shouldReceive('findUpcomingForStudent')->with(43)->andReturn([]);
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(42)->andReturn([]);
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(43)->andReturn([
|
||||
new Enrollment(offeringId: 8, studentId: 43, instructorId: 3, paymentId: 41, id: 40),
|
||||
]);
|
||||
|
||||
// The child's lesson is cancelled and its time freed, exactly as the
|
||||
// guardian's own would have been.
|
||||
$this->bookings->shouldReceive('updateStatus')->once()->with(12, Lesson::STATUS_CANCELLED)->andReturn(true);
|
||||
$this->availability->shouldReceive('release')->once()->with(7)->andReturn(true);
|
||||
$this->enrollments->shouldReceive('updateStatus')->once()->with(40, Enrollment::STATUS_CANCELLED)->andReturn(true);
|
||||
$this->payments->shouldReceive('voidPending')->with(40)->once();
|
||||
$this->payments->shouldReceive('voidPending')->with(41)->once();
|
||||
|
||||
// Then the link row and the account itself.
|
||||
$this->links->shouldReceive('delete')->once()->with(5, 42)->andReturn(true);
|
||||
$this->links->shouldReceive('delete')->once()->with(5, 43)->andReturn(true);
|
||||
$this->guardians->shouldReceive('deleteUser')->once()->with(42);
|
||||
$this->guardians->shouldReceive('deleteUser')->once()->with(43);
|
||||
|
||||
$this->cleanup->releaseBookings(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deleting a child fires `delete_user` again, which lands back in this same
|
||||
* handler. It must return without redoing the release — and a self-link,
|
||||
* however it got into the table, must not recurse for ever.
|
||||
*/
|
||||
public function testAChildAlreadyDealtWithIsNotProcessedTwice(): void
|
||||
{
|
||||
$this->bookings->shouldReceive('findUpcomingForStudent')->with(5)->andReturn([]);
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([]);
|
||||
|
||||
$this->links->shouldReceive('findByGuardian')->with(5)->andReturn([
|
||||
new GuardianLink(guardianId: 5, studentId: 42, id: 1),
|
||||
// A duplicate row, and a self-link: neither may cause a second pass.
|
||||
new GuardianLink(guardianId: 5, studentId: 42, id: 2),
|
||||
new GuardianLink(guardianId: 5, studentId: 5, id: 3),
|
||||
]);
|
||||
|
||||
$this->bookings->shouldReceive('findUpcomingForStudent')->with(42)->once()->andReturn([]);
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(42)->once()->andReturn([]);
|
||||
$this->links->shouldReceive('delete')->once()->with(5, 42)->andReturn(true);
|
||||
$this->guardians->shouldReceive('deleteUser')->once()->with(42);
|
||||
|
||||
$this->cleanup->releaseBookings(5);
|
||||
|
||||
// The re-entrant call the child's own deletion triggers is a no-op.
|
||||
$this->cleanup->releaseBookings(42);
|
||||
}
|
||||
|
||||
/**
|
||||
* A child's own deletion (from the family screen, say) touches nothing but
|
||||
* that child — they have nobody linked beneath them.
|
||||
*/
|
||||
public function testDeletingAStudentWithNoChildrenDeletesNobodyElse(): void
|
||||
{
|
||||
$this->bookings->shouldReceive('findUpcomingForStudent')->with(42)->andReturn([]);
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(42)->andReturn([]);
|
||||
$this->links->shouldReceive('findByGuardian')->with(42)->andReturn([]);
|
||||
|
||||
$this->guardians->shouldNotReceive('deleteUser');
|
||||
$this->links->shouldNotReceive('delete');
|
||||
|
||||
$this->cleanup->releaseBookings(42);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Unsupervised\Schedular\Tests\Unit\GroupClass;
|
||||
|
||||
use Brain\Monkey\Functions;
|
||||
use Mockery;
|
||||
use Unsupervised\Schedular\GroupClass\Enrollment;
|
||||
use Unsupervised\Schedular\GroupClass\EnrollmentRepository;
|
||||
@@ -56,6 +57,7 @@ class SessionScheduleTest extends TestCase
|
||||
array_column($rows, 'start_dt')
|
||||
);
|
||||
self::assertSame('2026-09-08 17:00:00', $rows[0]['end_dt']);
|
||||
self::assertNull($rows[0]['schedule']);
|
||||
self::assertSame('Choir', $rows[0]['offering_title']);
|
||||
self::assertSame(40, $rows[0]['enrollment_id']);
|
||||
self::assertSame(3, $rows[0]['instructor_id']);
|
||||
@@ -115,26 +117,132 @@ class SessionScheduleTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* A class with no time set has no derivable sessions, so it is left out of a
|
||||
* dated list rather than shown at a time nobody chose.
|
||||
* Both the class time and the duration are optional on the offering form, and
|
||||
* the schedule note exists so a studio can say "Tuesdays 4:00pm" instead of
|
||||
* pinning the class to a clock. A class configured that way used to vanish
|
||||
* from the list entirely — the bug this covers. It now gets one row carrying
|
||||
* the note in place of a date.
|
||||
*/
|
||||
public function testAClassWithoutAScheduleYieldsNoRows(): void
|
||||
public function testAClassWithNoClassTimeStillGetsARowDescribedInWords(): void
|
||||
{
|
||||
$undated = new Offering(
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([
|
||||
new Enrollment(offeringId: 8, studentId: 5, instructorId: 3, id: 40),
|
||||
]);
|
||||
$this->offerings->shouldReceive('findById')->with(8)->andReturn(new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
durationMinutes: 60,
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-12-08',
|
||||
scheduleNote: 'Tuesdays 4:00pm',
|
||||
id: 8,
|
||||
));
|
||||
|
||||
$rows = $this->schedule->upcomingForStudent(5, '2026-09-01 00:00:00');
|
||||
|
||||
self::assertCount(1, $rows);
|
||||
self::assertSame('Tuesdays 4:00pm', $rows[0]['schedule']);
|
||||
self::assertSame('Choir', $rows[0]['offering_title']);
|
||||
// A sort key, not a claim about the time: the class has not started yet,
|
||||
// so it sorts to its first day.
|
||||
self::assertSame('2026-09-08 00:00:00', $rows[0]['start_dt']);
|
||||
self::assertSame('', $rows[0]['end_dt']);
|
||||
}
|
||||
|
||||
/** Without a note, the term dates do the describing. */
|
||||
public function testAnUndatedClassFallsBackToItsTermDates(): void
|
||||
{
|
||||
Functions\when('mysql2date')->alias(
|
||||
static fn (string $format, string $date): string => date($format, (int) strtotime($date))
|
||||
);
|
||||
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([
|
||||
new Enrollment(offeringId: 8, studentId: 5, instructorId: 3, id: 40),
|
||||
]);
|
||||
$this->offerings->shouldReceive('findById')->with(8)->andReturn($undated);
|
||||
$this->offerings->shouldReceive('findById')->with(8)->andReturn(new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-12-08',
|
||||
id: 8,
|
||||
));
|
||||
|
||||
self::assertSame([], $this->schedule->upcomingForStudent(5, '2026-09-01 00:00:00'));
|
||||
$rows = $this->schedule->upcomingForStudent(5, '2026-09-01 00:00:00');
|
||||
|
||||
self::assertSame('Sep 8, 2026 – Dec 8, 2026', $rows[0]['schedule']);
|
||||
}
|
||||
|
||||
/**
|
||||
* A term already under way sorts to "now" rather than to a start date in the
|
||||
* past, so an ongoing class reads as current instead of dropping to the
|
||||
* bottom of a list ordered by time.
|
||||
*/
|
||||
public function testAnUndatedClassAlreadyUnderWaySortsToNow(): void
|
||||
{
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([
|
||||
new Enrollment(offeringId: 8, studentId: 5, instructorId: 3, id: 40),
|
||||
]);
|
||||
$this->offerings->shouldReceive('findById')->with(8)->andReturn(new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-12-08',
|
||||
scheduleNote: 'Tuesdays 4:00pm',
|
||||
id: 8,
|
||||
));
|
||||
|
||||
$rows = $this->schedule->upcomingForStudent(5, '2026-10-01 09:00:00');
|
||||
|
||||
self::assertSame('2026-10-01 09:00:00', $rows[0]['start_dt']);
|
||||
}
|
||||
|
||||
/** An undated class whose last day has passed is over, and drops out. */
|
||||
public function testAnUndatedClassThatHasFinishedIsDropped(): void
|
||||
{
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([
|
||||
new Enrollment(offeringId: 8, studentId: 5, instructorId: 3, id: 40),
|
||||
]);
|
||||
$this->offerings->shouldReceive('findById')->with(8)->andReturn(new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-12-08',
|
||||
scheduleNote: 'Tuesdays 4:00pm',
|
||||
id: 8,
|
||||
));
|
||||
|
||||
self::assertSame([], $this->schedule->upcomingForStudent(5, '2026-12-09 00:00:00'));
|
||||
}
|
||||
|
||||
/**
|
||||
* A class time but no duration: the dates are still known, so they are still
|
||||
* listed — the row just says when it starts and not when it ends, rather than
|
||||
* inventing a finish.
|
||||
*/
|
||||
public function testAClassWithNoDurationKeepsItsDatesAndLeavesTheEndOpen(): void
|
||||
{
|
||||
$this->enrollments->shouldReceive('findByStudent')->with(5)->andReturn([
|
||||
new Enrollment(offeringId: 8, studentId: 5, instructorId: 3, id: 40),
|
||||
]);
|
||||
$this->offerings->shouldReceive('findById')->with(8)->andReturn(new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-09-15',
|
||||
classTime: '16:00:00',
|
||||
id: 8,
|
||||
));
|
||||
|
||||
$rows = $this->schedule->upcomingForStudent(5, '2026-09-01 00:00:00');
|
||||
|
||||
self::assertSame(['2026-09-08 16:00:00', '2026-09-15 16:00:00'], array_column($rows, 'start_dt'));
|
||||
self::assertSame(['', ''], array_column($rows, 'end_dt'));
|
||||
self::assertNull($rows[0]['schedule']);
|
||||
}
|
||||
|
||||
public function testADeletedOfferingIsSkippedRatherThanFatal(): void
|
||||
|
||||
@@ -128,6 +128,96 @@ class OfferingTest extends TestCase
|
||||
self::assertSame([], $noDuration->sessionWindows());
|
||||
}
|
||||
|
||||
/**
|
||||
* Knowing *when* a class meets is a separate question from knowing how long
|
||||
* it runs, so the dates survive a missing duration even though the windows
|
||||
* (which need both ends) do not.
|
||||
*/
|
||||
public function testSessionStartsNeedsNoDuration(): void
|
||||
{
|
||||
$noDuration = new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-09-22',
|
||||
classTime: '16:00:00',
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
['2026-09-08 16:00:00', '2026-09-15 16:00:00', '2026-09-22 16:00:00'],
|
||||
$noDuration->sessionStarts()
|
||||
);
|
||||
self::assertSame([], $noDuration->sessionWindows());
|
||||
}
|
||||
|
||||
public function testSessionStartsEmptyWithoutADateOrATime(): void
|
||||
{
|
||||
$noTime = new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
);
|
||||
self::assertSame([], $noTime->sessionStarts());
|
||||
|
||||
$noDate = new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
classTime: '16:00:00',
|
||||
);
|
||||
self::assertSame([], $noDate->sessionStarts());
|
||||
}
|
||||
|
||||
public function testLastClassDayPrefersTheTermEnd(): void
|
||||
{
|
||||
$run = new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-12-08',
|
||||
);
|
||||
self::assertSame('2026-12-08', $run->lastClassDay());
|
||||
|
||||
$oneOff = new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Recital',
|
||||
termStart: '2026-09-08',
|
||||
);
|
||||
self::assertSame('2026-09-08', $oneOff->lastClassDay());
|
||||
|
||||
$undated = new Offering(instructorId: 3, kind: Offering::KIND_GROUP_CLASS, title: 'Choir');
|
||||
self::assertNull($undated->lastClassDay());
|
||||
}
|
||||
|
||||
/**
|
||||
* The studio's own wording wins: the schedule-note field exists precisely so
|
||||
* a class can describe when it meets without being pinned to a clock.
|
||||
*/
|
||||
public function testScheduleLabelPrefersTheScheduleNote(): void
|
||||
{
|
||||
$offering = new Offering(
|
||||
instructorId: 3,
|
||||
kind: Offering::KIND_GROUP_CLASS,
|
||||
title: 'Choir',
|
||||
termStart: '2026-09-08',
|
||||
termEnd: '2026-12-08',
|
||||
scheduleNote: ' Tuesdays 4:00pm ',
|
||||
);
|
||||
|
||||
self::assertSame('Tuesdays 4:00pm', $offering->scheduleLabel());
|
||||
}
|
||||
|
||||
public function testScheduleLabelSaysSoWhenNothingIsSet(): void
|
||||
{
|
||||
$offering = new Offering(instructorId: 3, kind: Offering::KIND_GROUP_CLASS, title: 'Choir');
|
||||
|
||||
self::assertSame('Schedule to be confirmed', $offering->scheduleLabel());
|
||||
}
|
||||
|
||||
public function testDefaults(): void
|
||||
{
|
||||
$offering = new Offering(1, Offering::KIND_GROUP_CLASS, 'Choir');
|
||||
|
||||
Reference in New Issue
Block a user