Nine test files under tests/Feature/Artist/ exercising:
ArtistEngagementStateMachineTest 8 tests — terminal blocks, conditional
gates (Option/Contracted), full happy
path, cancel cascade
LaneCascadeServiceTest 5 tests — simple move, cascade-bump,
version mismatch, park, unpark
BumaVatCalculationTest 6 tests — D26 formula coverage:
Organisation/BookingAgency/NotApplicable,
VAT off, breakdown sum, zero fee
DemoteExpiredOptionsTest 4 tests — expired demote, future
untouched, non-Option untouched, run
twice → single option_expired entry
IdempotencyKey60sRedisTest 4 tests — missing header 400, first
cache, replay header, failed not cached
ArtistControllerTest 8 tests — index/create/destroy + cross-
tenant + duplicate detection + restore
StageControllerTest 7 tests — create + uniqueness, destroy
cascade-park, reorder permutation,
replaceDays orphan 409 + force_orphan
ArtistEngagementControllerTest 5 tests — index/create/update/destroy +
422 on invalid status transition
TimetableMoveControllerTest 3 tests — happy path with idempotency
header, missing header → 400, version
mismatch → 409
ArtistPolicyTest 6 tests — role checks, cross-tenant
denial, super_admin bypass, D27 active-
engagement gate
ActivityLogShapeTest 4 tests — performance.moved cascade
props, status_changed vs cancelled,
stage.day_added subject + props,
stage.reordered on Event subject
Bug fixes surfaced by Phase C:
Schema reality: events table uses `start_date`/`end_date` (date), not
`start_at`/`end_at`. Updated WithinEventBounds rule and the two stage_day
resolvers (LaneCascadeService + MoveTimetablePerformanceRequest) to
query the actual columns. ArtistResource.engagements_summary upcoming
filter likewise.
performances table has no organisation_id column (FK-chain via
engagement_id). Removed the org-id filter from the Rule::exists in
MoveTimetablePerformanceRequest; cross-tenant is caught by the policy
in TimetableMoveController.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules\Artist;
|
|
|
|
use App\Models\Event;
|
|
use Carbon\CarbonImmutable;
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
/**
|
|
* Validates that a candidate datetime sits inside the event's
|
|
* [start_at, end_at] window. Works for flat events (single window)
|
|
* and for sub-events (sub-event window); festival-level events are
|
|
* usually not the target — the FormRequest passes the *sub-event* id
|
|
* for performances and the *containing* event for the stage's day.
|
|
*
|
|
* Rule passes silently when value is null or when the event cannot
|
|
* be found (the FormRequest owns the `required`/`exists` decision).
|
|
*/
|
|
final class WithinEventBounds implements ValidationRule
|
|
{
|
|
public function __construct(
|
|
private readonly ?string $eventId,
|
|
) {}
|
|
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if ($value === null || $this->eventId === null) {
|
|
return;
|
|
}
|
|
|
|
$event = Event::withoutGlobalScopes()->find($this->eventId);
|
|
if ($event === null) {
|
|
return;
|
|
}
|
|
|
|
$candidate = CarbonImmutable::parse((string) $value);
|
|
$start = CarbonImmutable::instance($event->start_date)->startOfDay();
|
|
$end = CarbonImmutable::instance($event->end_date)->endOfDay();
|
|
|
|
if ($candidate->lt($start) || $candidate->gt($end)) {
|
|
$fail(sprintf(
|
|
'De datum moet binnen het evenement (%s — %s) vallen.',
|
|
$start->format('Y-m-d H:i'),
|
|
$end->format('Y-m-d H:i'),
|
|
));
|
|
}
|
|
}
|
|
}
|