mirror of
https://github.com/danog/Valinor.git
synced 2024-12-12 09:09:38 +01:00
d3b1dcb64e
The class `\CuyZ\Valinor\Mapper\Tree\Node` has been refactored to remove access to unwanted methods that were not supposed to be part of the public API. Below are a list of all changes: - New methods `$node->sourceFilled()` and `$node->sourceValue()` allow accessing the source value. - The method `$node->value()` has been renamed to `$node->mappedValue()` and will throw an exception if the node is not value. - The method `$node->type()` now returns a string. - The methods `$message->name()`, `$message->path()`, `$message->type()` and `$message->value()` have been deprecated in favor of the new method `$message->node()`. - The message parameter `{original_value}` has been deprecated in favor of `{source_value}`.
32 lines
787 B
PHP
32 lines
787 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace CuyZ\Valinor\Tests\Unit\Mapper\Tree;
|
|
|
|
use CuyZ\Valinor\Mapper\Tree\Node;
|
|
use CuyZ\Valinor\Mapper\Tree\NodeTraverser;
|
|
use CuyZ\Valinor\Tests\Fake\Mapper\Tree\FakeNode;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class NodeTraverserTest extends TestCase
|
|
{
|
|
public function test_nodes_are_visited(): void
|
|
{
|
|
$children = [
|
|
'foo' => FakeNode::any(),
|
|
'bar' => FakeNode::any(),
|
|
];
|
|
|
|
$node = FakeNode::branch($children);
|
|
|
|
$visited = [...(new NodeTraverser(
|
|
fn (Node $node) => $node
|
|
))->traverse($node)];
|
|
|
|
self::assertContains($node, $visited);
|
|
self::assertContains($children['foo'], $visited);
|
|
self::assertContains($children['bar'], $visited);
|
|
}
|
|
}
|