mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Regex > createSlug() method > returns slug for given value
This commit is contained in:
@@ -624,6 +624,17 @@ class RegexTest extends BaseTestCase
|
||||
self::assertEquals($expected, Regex::getValidColorHexValue($color));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value Value that should be transformed to slug
|
||||
* @param string $expected Expected slug
|
||||
*
|
||||
* @dataProvider provideValueSlug
|
||||
*/
|
||||
public function testCreateSlug($value, $expected)
|
||||
{
|
||||
self::assertSame($expected, Regex::createSlug($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides name of bundle and information if it's valid name
|
||||
*
|
||||
@@ -1694,6 +1705,89 @@ class RegexTest extends BaseTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide value to create slug
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideValueSlug()
|
||||
{
|
||||
yield[
|
||||
[],
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
null,
|
||||
false,
|
||||
];
|
||||
|
||||
yield[
|
||||
'',
|
||||
'',
|
||||
];
|
||||
|
||||
yield[
|
||||
1234,
|
||||
'1234',
|
||||
];
|
||||
|
||||
yield[
|
||||
'1234',
|
||||
'1234',
|
||||
];
|
||||
|
||||
yield[
|
||||
'1/2/3/4',
|
||||
'1234',
|
||||
];
|
||||
|
||||
yield[
|
||||
'1 / 2 / 3 / 4',
|
||||
'1-2-3-4',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test',
|
||||
'test',
|
||||
];
|
||||
|
||||
yield[
|
||||
'test test',
|
||||
'test-test',
|
||||
];
|
||||
|
||||
yield[
|
||||
'lorem ipsum dolor sit',
|
||||
'lorem-ipsum-dolor-sit',
|
||||
];
|
||||
|
||||
yield[
|
||||
'Lorem ipsum. Dolor sit 12.34 amet.',
|
||||
'lorem-ipsum-dolor-sit-1234-amet',
|
||||
];
|
||||
|
||||
yield[
|
||||
'Was sind Löwen, Bären, Vögel und Käfer (für die Prüfung)?',
|
||||
'was-sind-lowen-baren-vogel-und-kafer-fur-die-prufung',
|
||||
];
|
||||
|
||||
yield[
|
||||
'äöü (ÄÖÜ)',
|
||||
'aou-aou',
|
||||
];
|
||||
|
||||
yield[
|
||||
'Półka dębowa. Kolor: żółędziowy. Wymiary: 80 x 30 cm.',
|
||||
'polka-debowa-kolor-zoledziowy-wymiary-80-x-30-cm',
|
||||
];
|
||||
|
||||
yield[
|
||||
'ąęółńśżźć (ĄĘÓŁŃŚŻŹĆ)',
|
||||
'aeolnszzc-aeolnszzc',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user