respect-validation/tests/unit/Message/Stringifier/QuotedStringifierTest.php
Henrique Moody bf9b970e24
Move important value objects to the root namespace
The `Id`, `Name`, and `Path` value objects are not only message-related
concerns, they're part of the core of the library, hence it makes sense
to place them at the root namespace.
2025-12-21 11:14:47 +01:00

45 lines
1.3 KiB
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Message\Stringifier;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Respect\Stringifier\Quoters\StandardQuoter;
use Respect\Validation\Message\Placeholder\Quoted;
use Respect\Validation\Test\TestCase;
#[CoversClass(QuotedStringifier::class)]
final class QuotedStringifierTest extends TestCase
{
#[Test]
#[DataProvider('providerForAnyValues')]
public function itShouldNotStringifyWhenValueIsNotAnInstanceOfQuoted(mixed $value): void
{
$quoter = new StandardQuoter(1);
$stringifier = new QuotedStringifier($quoter);
self::assertNull($stringifier->stringify($value, 0));
}
#[Test]
#[DataProvider('providerForStringTypes')]
public function itShouldStringifyWhenValueIsAnInstanceOfQuoted(string $value): void
{
$quoted = new Quoted($value);
$quoter = new StandardQuoter(1);
$stringifier = new QuotedStringifier($quoter);
$expected = $quoter->quote($quoted->value, 0);
$actual = $stringifier->stringify($quoted, 0);
self::assertSame($expected, $actual);
}
}