isRoot()); self::assertSame('nodeName', $node->name()); self::assertSame('some.node.path', $node->path()); self::assertSame('string', $node->type()); self::assertSame('some source value', $node->sourceValue()); self::assertSame('some value', $node->value()); self::assertSame('some value', $node->mappedValue()); self::assertSame(true, $node->isValid()); self::assertSame('some message', (string)$node->messages()[0]); self::assertSame([$child], $node->children()); } public function test_error_message_makes_node_not_valid(): void { $message = new FakeErrorMessage(); $node = new Node( true, 'nodeName', 'some.node.path', 'string', true, 'some source value', 'some value', [$message], [] ); self::assertSame(false, $node->isValid()); } public function test_invalid_child_makes_root_node_not_valid(): void { $message = new FakeErrorMessage(); $node = new Node( true, '', '*root*', 'string', true, 'some source value', 'some value', [], [ new Node( false, 'nodeName', 'some.node.path', 'string', true, 'some source value', 'some value', [$message], [] ) ] ); self::assertSame(false, $node->isValid()); } public function test_get_source_value_not_filled_throws_exception(): void { $this->expectException(SourceValueWasNotFilled::class); $this->expectExceptionCode(1657466107); $this->expectExceptionMessage('Source was not filled at path `some.node.path`; use method `$node->sourceFilled()`.'); (new Node( true, 'nodeName', 'some.node.path', 'string', false, null, 'some value', [], [] ))->sourceValue(); } public function test_get_mapped_value_from_invalid_node_throws_exception(): void { $this->expectException(InvalidNodeHasNoMappedValue::class); $this->expectExceptionCode(1657466305); $this->expectExceptionMessage('Cannot get mapped value for invalid node at path `some.node.path`; use method `$node->isValid()`.'); (new Node( true, 'nodeName', 'some.node.path', 'string', true, 'some source value', null, [new FakeErrorMessage()], [] ))->mappedValue(); } }