2021-11-30 12:59:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace CuyZ\Valinor\Tests\Integration\Mapping\Source;
|
|
|
|
|
|
|
|
use CuyZ\Valinor\Mapper\MappingError;
|
|
|
|
use CuyZ\Valinor\Mapper\Source\YamlSource;
|
2022-05-22 20:43:01 +02:00
|
|
|
use CuyZ\Valinor\MapperBuilder;
|
2021-11-30 12:59:50 +01:00
|
|
|
use CuyZ\Valinor\Tests\Integration\IntegrationTest;
|
|
|
|
use CuyZ\Valinor\Tests\Integration\Mapping\Fixture\SimpleObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @requires extension yaml
|
|
|
|
*/
|
|
|
|
final class YamlSourceMappingTest extends IntegrationTest
|
|
|
|
{
|
|
|
|
public function test_yaml_source_is_mapped_correctly(): void
|
|
|
|
{
|
|
|
|
try {
|
2022-05-22 20:43:01 +02:00
|
|
|
$object = (new MapperBuilder())->mapper()->map(
|
2021-11-30 12:59:50 +01:00
|
|
|
SimpleObject::class,
|
|
|
|
new YamlSource('value: foo')
|
|
|
|
);
|
|
|
|
} catch (MappingError $error) {
|
|
|
|
$this->mappingFail($error);
|
|
|
|
}
|
|
|
|
|
|
|
|
self::assertSame('foo', $object->value);
|
|
|
|
}
|
|
|
|
}
|