2021-12-29 00:09:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace CuyZ\Valinor\Tests\Integration\Mapping\Other;
|
|
|
|
|
|
|
|
use CuyZ\Valinor\Mapper\MappingError;
|
2022-05-22 20:43:01 +02:00
|
|
|
use CuyZ\Valinor\MapperBuilder;
|
2021-12-29 00:09:34 +01:00
|
|
|
use CuyZ\Valinor\Tests\Integration\IntegrationTest;
|
|
|
|
|
|
|
|
final class ArrayOfScalarMappingTest extends IntegrationTest
|
|
|
|
{
|
|
|
|
public function test_values_are_mapped_properly(): void
|
|
|
|
{
|
|
|
|
$source = [
|
|
|
|
'foo',
|
|
|
|
42,
|
|
|
|
1337.404,
|
|
|
|
];
|
|
|
|
|
|
|
|
try {
|
2022-05-22 20:43:01 +02:00
|
|
|
$result = (new MapperBuilder())->mapper()->map('string[]', $source);
|
2021-12-29 00:09:34 +01:00
|
|
|
} catch (MappingError $error) {
|
|
|
|
$this->mappingFail($error);
|
|
|
|
}
|
|
|
|
|
|
|
|
self::assertSame(['foo', '42', '1337.404'], $result);
|
|
|
|
}
|
|
|
|
}
|