expectException(AssertionError::class); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(Shell::root(new FakeType(), [])); } 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("Source must be iterable in order to be cast to `$type`, but is of type `string`."); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(Shell::root($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 cast an empty value to `$type`."); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(Shell::root($type, null)); } public function test_build_with_missing_key_throws_exception(): void { $this->expectException(ShapedArrayElementMissing::class); $this->expectExceptionCode(1631613641); $this->expectExceptionMessage("Missing value `foo` of type `SomeType`."); $type = new ShapedArrayType(new ShapedArrayElement(new StringValueType('foo'), new FakeType('SomeType'))); (new RootNodeBuilder(new ShapedArrayNodeBuilder()))->build(Shell::root($type, [])); } }