-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTemplateFormatterTest.php
More file actions
45 lines (37 loc) · 1.4 KB
/
TemplateFormatterTest.php
File metadata and controls
45 lines (37 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* SPDX-FileCopyrightText: (c) Respect Project Contributors
* SPDX-License-Identifier: ISC
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
*/
declare(strict_types=1);
namespace Respect\StringFormatter\Test\Unit;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Respect\StringFormatter\TemplateFormatter;
// THIS IS A TEMPLATE - Copy and rename this file for your formatter tests
#[CoversClass(TemplateFormatter::class)]
final class TemplateFormatterTest extends TestCase
{
#[Test]
#[DataProvider('providerForValidFormattedString')]
public function testShouldFormatString(string $input, string $expected): void
{
$formatter = new TemplateFormatter();
$actual = $formatter->format($input);
self::assertSame($expected, $actual);
}
/** @return array<string, array{0: string, 1: string}> */
public static function providerForValidFormattedString(): array
{
return [
'empty strings' => ['', 'FORMATTED: '],
'ascii chars' => ['Hello, World!', 'FORMATTED: Hello, World!'],
'numbers' => ['1234567890', 'FORMATTED: 1234567890'],
'mixed alphanumeric' => ['User123', 'FORMATTED: User123'],
'special chars' => ['!@#$%^&*()', 'FORMATTED: !@#$%^&*()'],
];
}
}