= 8.1 */ final class EnumNodeBuilderTest extends TestCase { private RootNodeBuilder $builder; protected function setUp(): void { parent::setUp(); $this->builder = new RootNodeBuilder(new EnumNodeBuilder()); } public function test_invalid_type_fails_assertion(): void { $this->expectException(AssertionError::class); $this->builder->build(FakeShell::any()); } public function test_invalid_value_throws_exception(): void { $type = new EnumType(PureEnum::class); $this->expectException(InvalidEnumValue::class); $this->expectExceptionCode(1633093113); $this->expectExceptionMessage("Value 'foo' does not match any of 'FOO', 'BAR'."); $this->builder->build(FakeShell::new($type, 'foo')); } public function test_invalid_string_value_throws_exception(): void { $type = new EnumType(BackedStringEnum::class); $this->expectException(InvalidEnumValue::class); $this->expectExceptionCode(1633093113); $this->expectExceptionMessage("Value object(stdClass) does not match any of 'foo', 'bar'."); $this->builder->build(FakeShell::new($type, new stdClass())); } public function test_boolean_instead_of_integer_value_throws_exception(): void { $type = new EnumType(BackedIntegerEnum::class); $this->expectException(InvalidEnumValue::class); $this->expectExceptionCode(1633093113); $this->expectExceptionMessage('Value false does not match any of 42, 1337.'); $this->builder->build(FakeShell::new($type, false)); } public function test_invalid_integer_value_throws_exception(): void { $type = new EnumType(BackedIntegerEnum::class); $this->expectException(InvalidEnumValue::class); $this->expectExceptionCode(1633093113); $this->expectExceptionMessage('Value object(stdClass) does not match any of 42, 1337.'); $this->builder->build(FakeShell::new($type, new stdClass())); } }