Repository navigation
Expand file tree
/
Copy pathTextTest.php
More file actions
76 lines (68 loc) · 2.37 KB
/
Copy pathTextTest.php
File metadata and controls
76 lines (68 loc) · 2.37 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types=1);
namespace PHPForge\Debug\Tests\Helper;
use PHPForge\Debug\Helper\Text;
use PHPForge\Debug\Tests\Provider\{LineBreakProvider, UrlPathProvider};
use PHPUnit\Framework\Attributes\{DataProviderExternal, Group};
use PHPUnit\Framework\TestCase;
/**
* Unit tests for {@see Text} covering identifiers, Unicode case conversion, line break preservation, and captured URL
* display.
*
* {@see LineBreakProvider} and {@see UrlPathProvider} for test case data providers.
*/
#[Group('helpers')]
final class TextTest extends TestCase
{
public function testCamel2idConvertsUnderscoresAndCamelCase(): void
{
self::assertSame(
'app-asset-bundle',
Text::camel2id('App_assetBundle'),
'Underscores and CamelCase boundaries must use one canonical dash separator.',
);
}
public function testCamel2idLowercasesUnicodeLetters(): void
{
self::assertSame(
'árbol-über',
Text::camel2id('ÁrbolÜber'),
'Unicode uppercase letters must be lowercased with multibyte semantics.',
);
}
public function testCamel2idPreservesEmptyInput(): void
{
self::assertSame(
'',
Text::camel2id(''),
'Empty input must remain empty.',
);
}
#[DataProviderExternal(LineBreakProvider::class, 'htmlLineBreaks')]
public function testPreserveHtmlLineBreaksKeepsMarkupAndEncodesLineBreaks(string $html, string $expected): void
{
self::assertSame(
$expected,
Text::preserveHtmlLineBreaks($html),
'Markup must stay unescaped with every line break as ` `.',
);
}
#[DataProviderExternal(LineBreakProvider::class, 'lineBreaks')]
public function testPreserveLineBreaksEscapesTextAndEncodesLineBreaks(string $text, string $expected): void
{
self::assertSame(
$expected,
Text::preserveLineBreaks($text),
'Content must be escaped once with every line break as ` `.',
);
}
#[DataProviderExternal(UrlPathProvider::class, 'paths')]
public function testUrlToPathPreservesCapturedDisplay(string $url, string $expected): void
{
self::assertSame(
$expected,
Text::urlToPath($url),
'Captured URL display must match both adapters exactly.',
);
}
}