Valinor/tests/Unit/Mapper/Tree/Builder/CasterNodeBuilderTest.php

27 lines
817 B
PHP
Raw Normal View History

2021-11-28 17:43:02 +01:00
<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Unit\Mapper\Tree\Builder;
use CuyZ\Valinor\Mapper\Tree\Builder\CasterNodeBuilder;
use CuyZ\Valinor\Mapper\Tree\Builder\RootNodeBuilder;
use CuyZ\Valinor\Mapper\Tree\Exception\NoCasterForType;
use CuyZ\Valinor\Mapper\Tree\Shell;
use CuyZ\Valinor\Tests\Fake\Type\FakeType;
use PHPUnit\Framework\TestCase;
final class CasterNodeBuilderTest extends TestCase
{
public function test_no_caster_found_throws_exception(): void
{
$type = new FakeType();
$this->expectException(NoCasterForType::class);
$this->expectExceptionCode(1630693475);
$this->expectExceptionMessage("No caster was found to convert to type `$type`.");
(new RootNodeBuilder(new CasterNodeBuilder([])))->build(Shell::root($type, []));
}
}