Valinor/tests/Integration/Mapping/ValueAlteringMappingTest.php
Romain Canon 396f64a524 feat: initial release
🎉
2021-11-28 18:21:56 +01:00

33 lines
976 B
PHP

<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Integration\Mapping;
use CuyZ\Valinor\Mapper\MappingError;
use CuyZ\Valinor\Tests\Integration\IntegrationTest;
use CuyZ\Valinor\Tests\Integration\Mapping\Fixture\SimpleObject;
use function strtolower;
use function strtoupper;
final class ValueAlteringMappingTest extends IntegrationTest
{
public function test_alter_string_alters_value(): void
{
try {
$result = $this->mapperBuilder
->alter(fn (string $value) => strtolower($value))
->alter(fn (string $value) => strtoupper($value))
->alter(/** @param string $value */ fn ($value) => $value . '!')
->alter(fn (int $value) => 42)
->mapper()
->map(SimpleObject::class, ['value' => 'foo']);
} catch (MappingError $error) {
$this->mappingFail($error);
}
self::assertSame('FOO!', $result->value);
}
}