makeWith(['trustLevel' => 80]); $this->assertSame(80, $binding->trustLevel); $this->assertSame('person', $binding->targetEntity); } public function test_trust_level_lower_bound(): void { $binding = $this->makeWith(['trustLevel' => 0]); $this->assertSame(0, $binding->trustLevel); } public function test_trust_level_upper_bound(): void { $binding = $this->makeWith(['trustLevel' => 100]); $this->assertSame(100, $binding->trustLevel); } public function test_trust_level_below_zero_throws(): void { $this->expectException(InvalidArgumentException::class); $this->makeWith(['trustLevel' => -1]); } public function test_trust_level_above_hundred_throws(): void { $this->expectException(InvalidArgumentException::class); $this->makeWith(['trustLevel' => 101]); } public function test_empty_target_entity_throws(): void { $this->expectException(InvalidArgumentException::class); $this->makeWith(['targetEntity' => '']); } public function test_empty_target_attribute_throws(): void { $this->expectException(InvalidArgumentException::class); $this->makeWith(['targetAttribute' => '']); } public function test_null_value_preserved_with_explicit_flag(): void { $binding = $this->makeWith([ 'value' => null, 'valueIsExplicit' => true, ]); $this->assertNull($binding->value); $this->assertTrue($binding->valueIsExplicit); } /** * @param array $overrides */ private function makeWith(array $overrides): ResolvedBinding { $defaults = [ 'sourceFormFieldId' => '01jq1k1k1k1k1k1k1k1k1k1k1k', 'bindingId' => '01jq1k1k1k1k1k1k1k1k1k1k1l', 'targetEntity' => 'person', 'targetAttribute' => 'email', 'targetType' => BindingTargetType::SCALAR, 'mergeStrategy' => FormFieldBindingMergeStrategy::Overwrite, 'trustLevel' => 50, 'isIdentityKey' => false, 'value' => 'jan@example.nl', 'valueIsExplicit' => true, ]; $args = array_merge($defaults, $overrides); return new ResolvedBinding( sourceFormFieldId: $args['sourceFormFieldId'], bindingId: $args['bindingId'], targetEntity: $args['targetEntity'], targetAttribute: $args['targetAttribute'], targetType: $args['targetType'], mergeStrategy: $args['mergeStrategy'], trustLevel: $args['trustLevel'], isIdentityKey: $args['isIdentityKey'], value: $args['value'], valueIsExplicit: $args['valueIsExplicit'], ); } }