|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\String; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\String\Slugger\AsciiSlugger; |
| 16 | + |
| 17 | +class AsciiSluggerTest extends TestCase |
| 18 | +{ |
| 19 | + public function provideSlugTests(): iterable |
| 20 | + { |
| 21 | + yield ['', '']; |
| 22 | + yield ['foo', ' foo ']; |
| 23 | + yield ['foo-bar', 'foo bar']; |
| 24 | + |
| 25 | + yield ['foo-bar', 'foo@bar', '-']; |
| 26 | + yield ['foo-at-bar', 'foo@bar', '-', 'en']; |
| 27 | + |
| 28 | + yield ['e-a', 'é$!à']; |
| 29 | + yield ['e_a', 'é$!à', '_']; |
| 30 | + |
| 31 | + yield ['a', 'ä']; |
| 32 | + yield ['a', 'ä', '-', 'fr']; |
| 33 | + yield ['ae', 'ä', '-', 'de']; |
| 34 | + yield ['ae', 'ä', '-', 'de_fr']; // Ensure we get the parent locale |
| 35 | + yield ['g', 'ғ', '-']; |
| 36 | + yield ['gh', 'ғ', '-', 'uz']; |
| 37 | + yield ['gh', 'ғ', '-', 'uz_fr']; // Ensure we get the parent locale |
| 38 | + } |
| 39 | + |
| 40 | + /** @dataProvider provideSlugTests */ |
| 41 | + public function testSlug(string $expected, string $string, string $separator = '-', string $locale = null) |
| 42 | + { |
| 43 | + $slugger = new AsciiSlugger(); |
| 44 | + |
| 45 | + $this->assertSame($expected, (string) $slugger->slug($string, $separator, $locale)); |
| 46 | + } |
| 47 | +} |
0 commit comments