Merge pull request 'Charge weekly reservations for every claimed occurrence and confirm the whole series' (#81) from fix/recurring-payment-amount into main
CI / Tests (PHP 8.1) (push) Successful in 38s
CI / Coding Standards (push) Successful in 2m47s
CI / Tests (PHP 8.2) (push) Successful in 43s
CI / No Debug Code (push) Successful in 3s
CI / Tests (PHP 8.3) (push) Successful in 2m39s
CI / PHPStan (push) Successful in 2m51s
CI / Build Plugin Zip (push) Successful in 2m43s
CI / Tests (PHP 8.1) (push) Successful in 38s
CI / Coding Standards (push) Successful in 2m47s
CI / Tests (PHP 8.2) (push) Successful in 43s
CI / No Debug Code (push) Successful in 3s
CI / Tests (PHP 8.3) (push) Successful in 2m39s
CI / PHPStan (push) Successful in 2m51s
CI / Build Plugin Zip (push) Successful in 2m43s
Reviewed-on: #81
This commit was merged in pull request #81.
This commit is contained in:
@@ -41,6 +41,9 @@ class PaymentServiceTest extends TestCase
|
||||
$this->stripe = Mockery::mock(StripeGateway::class);
|
||||
$this->settings->shouldReceive('etransferEmail')->andReturn('');
|
||||
$this->settings->shouldReceive('hstRate')->andReturn(0.0)->byDefault();
|
||||
// Confirming a lesson looks it up to detect a weekly series; single
|
||||
// lessons (or a lookup miss) fall back to the per-lesson update.
|
||||
$this->bookings->shouldReceive('findById')->andReturn(null)->byDefault();
|
||||
|
||||
$this->service = new PaymentService(
|
||||
$this->payments,
|
||||
@@ -180,6 +183,23 @@ class PaymentServiceTest extends TestCase
|
||||
self::assertTrue($this->service->markPaid(70));
|
||||
}
|
||||
|
||||
public function testMarkPaidConfirmsEveryLessonInAWeeklySeries(): void
|
||||
{
|
||||
$this->payments->shouldReceive('findById')->with(70)->andReturn($this->payment(Payment::METHOD_ETRANSFER, Payment::STATUS_PENDING, 70));
|
||||
$this->payments->shouldReceive('markPaid')->once()->with(70, 'USC-70')->andReturn(true);
|
||||
|
||||
// The anchor lesson (registration_id 12) belongs to series 12: the whole
|
||||
// series is confirmed, not just the anchor row.
|
||||
$this->bookings->shouldReceive('findById')->with(12)->andReturn(
|
||||
new Lesson(slotId: 10, studentId: 5, instructorId: 3, recurrence: Lesson::RECURRENCE_WEEKLY, seriesId: 12, id: 12)
|
||||
);
|
||||
$this->bookings->shouldReceive('updateStatusForSeries')->once()->with(12, Lesson::STATUS_CONFIRMED)->andReturn(true);
|
||||
$this->bookings->shouldNotReceive('updateStatus');
|
||||
$this->mailer->shouldReceive('send')->andReturn(false);
|
||||
|
||||
self::assertTrue($this->service->markPaid(70));
|
||||
}
|
||||
|
||||
public function testMarkPaidReturnsFalseWhenMissing(): void
|
||||
{
|
||||
$this->payments->shouldReceive('findById')->with(99)->andReturn(null);
|
||||
|
||||
Reference in New Issue
Block a user