|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\String\AbstractString;
|
| 16 | +use function Symfony\Component\String\b; |
16 | 17 | use Symfony\Component\String\ByteString;
|
17 | 18 | use function Symfony\Component\String\s;
|
| 19 | +use function Symfony\Component\String\u; |
18 | 20 | use Symfony\Component\String\UnicodeString;
|
19 | 21 |
|
20 | 22 | final class FunctionsTest extends TestCase
|
21 | 23 | {
|
22 | 24 | /**
|
23 |
| - * @dataProvider provideStrings |
| 25 | + * @dataProvider provideSStrings |
24 | 26 | */
|
25 |
| - public function testS(AbstractString $expected, string $input) |
| 27 | + public function testS(AbstractString $expected, ?string $input) |
26 | 28 | {
|
27 | 29 | $this->assertEquals($expected, s($input));
|
28 | 30 | }
|
29 | 31 |
|
30 |
| - public function provideStrings(): array |
| 32 | + public function provideSStrings(): array |
31 | 33 | {
|
32 | 34 | return [
|
| 35 | + [new UnicodeString(''), ''], |
| 36 | + [new UnicodeString(''), null], |
33 | 37 | [new UnicodeString('foo'), 'foo'],
|
34 | 38 | [new UnicodeString('अनुच्छेद'), 'अनुच्छेद'],
|
35 | 39 | [new ByteString("b\x80ar"), "b\x80ar"],
|
36 | 40 | [new ByteString("\xfe\xff"), "\xfe\xff"],
|
37 | 41 | ];
|
38 | 42 | }
|
| 43 | + |
| 44 | + /** |
| 45 | + * @dataProvider provideUStrings |
| 46 | + */ |
| 47 | + public function testU(UnicodeString $expected, ?string $input) |
| 48 | + { |
| 49 | + $this->assertEquals($expected, u($input)); |
| 50 | + } |
| 51 | + |
| 52 | + public function provideUStrings(): array |
| 53 | + { |
| 54 | + return [ |
| 55 | + [new UnicodeString(''), ''], |
| 56 | + [new UnicodeString(''), null], |
| 57 | + [new UnicodeString('foo'), 'foo'], |
| 58 | + [new UnicodeString('अनुच्छेद'), 'अनुच्छेद'], |
| 59 | + ]; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @dataProvider provideBStrings |
| 64 | + */ |
| 65 | + public function testB(ByteString $expected, ?string $input) |
| 66 | + { |
| 67 | + $this->assertEquals($expected, b($input)); |
| 68 | + } |
| 69 | + |
| 70 | + public function provideBStrings(): array |
| 71 | + { |
| 72 | + return [ |
| 73 | + [new ByteString(''), ''], |
| 74 | + [new ByteString(''), null], |
| 75 | + [new ByteString("b\x80ar"), "b\x80ar"], |
| 76 | + [new ByteString("\xfe\xff"), "\xfe\xff"], |
| 77 | + ]; |
| 78 | + } |
39 | 79 | }
|
0 commit comments