expectException(AssertionError::class); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(FakeShell::any()); } public function test_build_with_invalid_source_throws_exception(): void { $type = new ShapedArrayType(new ShapedArrayElement(new StringValueType('foo'), new FakeType('SomeType'))); $this->expectException(SourceMustBeIterable::class); $this->expectExceptionCode(1618739163); $this->expectExceptionMessage("Value 'foo' does not match type `array{foo: SomeType}`."); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(FakeShell::new($type, 'foo')); } public function test_build_with_invalid_source_for_shaped_array_containing_object_type_throws_exception(): void { $type = new ShapedArrayType(new ShapedArrayElement(new StringValueType('foo'), new FakeObjectType())); $this->expectException(SourceMustBeIterable::class); $this->expectExceptionCode(1618739163); $this->expectExceptionMessage("Invalid value 'foo'."); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(FakeShell::new($type, 'foo')); } public function test_build_with_null_source_throws_exception(): void { $type = new ShapedArrayType(new ShapedArrayElement(new StringValueType('foo'), new FakeType('SomeType'))); $this->expectException(SourceMustBeIterable::class); $this->expectExceptionCode(1618739163); $this->expectExceptionMessage("Cannot be empty and must be filled with a value matching type `array{foo: SomeType}`."); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(FakeShell::new($type)); } public function test_build_with_missing_key_throws_exception(): void { $this->expectException(ShapedArrayElementMissing::class); $this->expectExceptionCode(1631613641); $this->expectExceptionMessage("Missing element `foo` matching type `SomeType`."); $type = new ShapedArrayType(new ShapedArrayElement(new StringValueType('foo'), new FakeType('SomeType'))); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(FakeShell::new($type, [])); } }