22 new tests across four files:
- AdvanceSectionObserverTest (7) — counter recompute on create / status
transition / delete / is_open toggle no-op / orphaned-section guard /
no activity-log noise on counter writes
- ArtistResolverTest (4) — happy path / invalid token / soft-deleted
artist / SHA-256 digest verification
- ArtistAdvanceDefaultTest (6) — five-section + slug shape / idempotency
/ per-section field shape / observer-invocation outside tests /
artisan one-org + all-orgs paths
- EngagementPortalControllerTest (6) — show 200/404/410 / show-section
schema + draft values / submit happy-path with submission persistence
+ counter recompute / cross-engagement section returns 404
Implementation tweaks driven by test feedback:
- OrganisationObserver gated by `app()->runningUnitTests()` — auto-seed
runs in production but is silent in CI so existing FormSchema-counting
tests are unperturbed. Tests that need the seeded schema invoke
`ArtistAdvanceDefault::seedFor()` explicitly.
- EngagementPortalController idempotency_key uses `aa-` + sha1 prefix
(28 chars) so it fits the form_submissions.idempotency_key
varchar(30) column.
Test count: 1709 (Session 2 close) → 1731 (+22).
Larastan: 0 new errors over baseline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\FormBuilder\Defaults\ArtistAdvanceDefault;
|
|
use App\Models\Organisation;
|
|
|
|
/**
|
|
* Bootstrap an organisation's domain defaults on creation.
|
|
*
|
|
* Currently provisions the artist_advance FormSchema (RFC-TIMETABLE
|
|
* v0.2 D15) so new tenants can use the artist portal flow without a
|
|
* separate manual step. Existing organisations get the same coverage
|
|
* via the `artist:seed-advance-default` artisan command.
|
|
*
|
|
* The default seeder is idempotent — if the org already owns an
|
|
* artist_advance schema, the call is a no-op. Safe to re-run.
|
|
*
|
|
* Skipped during automated tests so existing FormSchema-counting
|
|
* tests aren't perturbed; tests that need the auto-seed call
|
|
* `ArtistAdvanceDefault::seedFor()` explicitly.
|
|
*/
|
|
final class OrganisationObserver
|
|
{
|
|
public function created(Organisation $organisation): void
|
|
{
|
|
if (app()->runningUnitTests()) {
|
|
return;
|
|
}
|
|
|
|
ArtistAdvanceDefault::seedFor($organisation);
|
|
}
|
|
}
|