Skip to content

Commit cd4d8b0

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [String] Add tests for AsciiSlugger [Serializer] Fix get accessor regex in AnnotationLoader [HttpKernel] Fix passing `null` to `\trim()` method in LoggerDataCollector [Translation] Crowdin provider throw Exception when status is 50x Always attempt to listen for notifications add missing changelog entry for the AtLeastOneOf constraint validate nested constraints only if they are in the same group
2 parents f6ca040 + 69084de commit cd4d8b0

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Tests/Slugger/AsciiSluggerTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

Comments
 (0)