mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
The documents on translation were updated to feature symfony with an array provider. Duplicated container notes were extracted to a single configuration.md file. An API for accessing the messages, so users don't have to copy and paste them from the source or docs, was provided and TemplateResolver was refactored to use it.
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Message\Formatter;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Respect\Validation\Message\TemplateRegistry;
|
|
use Respect\Validation\Path;
|
|
use Respect\Validation\Test\Builders\ResultBuilder;
|
|
use Respect\Validation\Test\TestCase;
|
|
|
|
#[CoversClass(TemplateResolver::class)]
|
|
final class TemplateResolverTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function itShouldReturnResultWithTemplateWhenKeyExists(): void
|
|
{
|
|
$result = (new ResultBuilder())->path(new Path('foo-path'))->build();
|
|
$templates = ['foo-path' => 'My custom template'];
|
|
$sut = new TemplateResolver(new TemplateRegistry());
|
|
$template = $sut->getGivenTemplate($result, $templates);
|
|
|
|
self::assertSame('My custom template', $template);
|
|
}
|
|
}
|