buildValidSchema(); $provider = $this->app->make(ArtistAdvanceGuards::class); foreach ($provider->publishGuards() as $guard) { $result = $guard->evaluate($schema); $this->assertTrue( $result->passed, "Guard {$guard->code()} failed: {$result->messageKey}", ); } } public function test_append_on_scalar_target_fails(): void { $schema = $this->buildValidSchema(); FormFieldBinding::query() ->withoutGlobalScopes() ->whereIn('owner_id', $schema->fields->pluck('id')) ->where('target_attribute', 'stage_name') ->update(['merge_strategy' => FormFieldBindingMergeStrategy::Append->value]); $schema->load('fields.bindings'); $provider = $this->app->make(ArtistAdvanceGuards::class); $failedCodes = []; foreach ($provider->publishGuards() as $guard) { $result = $guard->evaluate($schema); if (! $result->passed) { $failedCodes[] = $guard->code(); } } $this->assertContains('append_strategy_requires_collection_target', $failedCodes); } private function buildValidSchema(): FormSchema { $schema = FormSchema::factory()->create([ 'purpose' => FormPurpose::ARTIST_ADVANCE->value, ]); $field = FormField::factory()->create(['form_schema_id' => $schema->id]); FormFieldBinding::factory()->forField($field)->entityOwned('artist', 'stage_name') ->create(['trust_level' => 70]); $schema->load(['fields.bindings', 'sections']); return $schema; } }