2021-11-28 17:43:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace CuyZ\Valinor\Tests\Integration\Mapping;
|
|
|
|
|
|
|
|
use CuyZ\Valinor\Mapper\MappingError;
|
2022-05-22 20:43:01 +02:00
|
|
|
use CuyZ\Valinor\MapperBuilder;
|
2021-11-28 17:43:02 +01:00
|
|
|
use CuyZ\Valinor\Tests\Integration\IntegrationTest;
|
|
|
|
use CuyZ\Valinor\Tests\Integration\Mapping\Fixture\ReadonlyValues;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @requires PHP >= 8.1
|
|
|
|
*/
|
|
|
|
final class ReadonlyMappingTest extends IntegrationTest
|
|
|
|
{
|
|
|
|
public function test_single_property_and_constructor_parameter_are_mapped_properly(): void
|
|
|
|
{
|
|
|
|
try {
|
2022-05-22 20:43:01 +02:00
|
|
|
$object = (new MapperBuilder())->mapper()->map(ReadonlyValues::class, [
|
2021-11-28 17:43:02 +01:00
|
|
|
'value' => 'foo',
|
|
|
|
]);
|
|
|
|
} catch (MappingError $error) {
|
|
|
|
$this->mappingFail($error);
|
|
|
|
}
|
|
|
|
|
|
|
|
self::assertSame('foo', $object->value);
|
|
|
|
}
|
|
|
|
}
|