Issue #3025727 by Krzysztof Domański, Matroskeen, alexpott: Using a data provider with array keys instead of comments in PhpTransliterationTest

merge-requests/666/head
catch 2021-05-12 23:34:06 +01:00
parent d8bba172f9
commit 35c43b5446
1 changed files with 90 additions and 52 deletions

View File

@ -124,58 +124,96 @@ class PhpTransliterationTest extends TestCase {
return [ return [
// Each test case is language code, input, output, unknown character, max // Each test case is language code, input, output, unknown character, max
// length. // length.
// Test ASCII in English. 'Test ASCII in English' => [
['en', $random, $random], 'en', $random, $random,
// Test ASCII in some other language with no overrides. ],
['fr', $random, $random], 'Test ASCII in some other language with no overrides' => [
// Test 3 and 4-byte characters in a language without overrides. 'fr', $random, $random,
// Note: if the data tables change, these will need to change too! They ],
// are set up to test that data table loading works, so values come 'Test 3-byte characters from data table in a language without overrides' => [
// directly from the data files. 'fr', $three_byte, 'c',
['fr', $three_byte, 'c'], ],
['fr', $four_byte, 'wii'], 'Test 4-byte characters from data table in a language without overrides' => [
// Test 5-byte characters. 'fr', $four_byte, 'wii',
['en', $five_byte, '??'], ],
// Test a language with no overrides. 'Test 5-byte characters not existing in the data table' => [
['en', $two_byte, 'A O U A O aouaohello'], 'en', $five_byte, '??',
// Test language overrides provided by core. ],
['de', $two_byte, 'Ae Oe Ue A O aeoeueaohello'], 'Test a language with no overrides' => [
['de', $random, $random], 'en', $two_byte, 'A O U A O aouaohello',
['da', $two_byte, 'A O U Aa Oe aouaaoehello'], ],
['da', $random, $random], 'Test language overrides in German' => [
['kg', $three_byte, 'ts'], 'de', $two_byte, 'Ae Oe Ue A O aeoeueaohello',
// Test strings in some other languages. ],
// Ukrainian pangram. 'Test ASCII in German language with overrides' => [
['uk', 'На подушечці форми любої є й ґудзик щоб пірʼя геть жовте сховати.', 'Na podushechtsi formy lyuboyi ye y gudzyk shchob pirya het zhovte skhovaty.'], 'de', $random, $random,
// Turkish, provided by drupal.org user Kartagis. ],
['tr', 'Abayı serdiler bize. Söyleyeceğim yüzlerine. Sanırım hepimiz aynı şeyi düşünüyoruz.', 'Abayi serdiler bize. Soyleyecegim yuzlerine. Sanirim hepimiz ayni seyi dusunuyoruz.'], 'Test language overrides in Danish' => [
// Max length. 'da', $two_byte, 'A O U Aa Oe aouaaoehello',
['de', $two_byte, 'Ae Oe Ue A O aeoe', '?', 17], ],
// Do not split up the transliteration of a single character. 'Test ASCII in Danish language with overrides' => [
['de', $two_byte, 'Ae Oe Ue A O aeoe', '?', 18], 'da', $random, $random,
// Illegal/unknown unicode. ],
['en', chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), '?????'], 'Test language overrides in Kyrgyz' => [
['en', chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), '-----', '-'], 'kg', $three_byte, 'ts',
['en', 'Hel' . chr(0x80) . 'o World', 'Hel?o World'], ],
['en', 'Hell' . chr(0x80) . ' World', 'Hell? World'], 'Test language overrides in Turkish' => [
// Non default replacement. 'tr', 'Abayı serdiler bize. Söyleyeceğim yüzlerine. Sanırım hepimiz aynı şeyi düşünüyoruz.', 'Abayi serdiler bize. Soyleyecegim yuzlerine. Sanirim hepimiz ayni seyi dusunuyoruz.',
['en', chr(0x80) . 'ello World', '_ello World', '_'], ],
// Keep the original question marks. 'Test language overrides in Ukrainian' => [
['en', chr(0xF8) . '?' . chr(0x80), '???'], 'uk', 'На подушечці форми любої є й ґудзик щоб пірʼя геть жовте сховати.', 'Na podushechtsi formy lyuboyi ye y gudzyk shchob pirya het zhovte skhovaty.',
['en', chr(0x80) . 'ello ? World?', '_ello ? World?', '_'], ],
['pl', 'aąeę' . chr(0x80) . 'oółżźz ?', 'aaee?oolzzz ?'], 'Max length' => [
// Non-US-ASCII replacement. 'de', $two_byte, 'Ae Oe Ue A O aeoe', '?', 17,
['en', chr(0x80) . 'ello World?', 'Oello World?', 'Ö'], ],
['pl', chr(0x80) . 'óóść', 'ooosc', 'ó'], 'Do not split up the transliteration of a single character' => [
// Ensure question marks are replaced when max length used. 'de', $two_byte, 'Ae Oe Ue A O aeoe', '?', 18,
['en', chr(0x80) . 'ello ? World?', '_ello ?', '_', 7], ],
// Empty replacement. 'Illegal/unknown unicode' => [
['en', chr(0x80) . 'ello World' . chr(0xF8), 'ello World', ''], 'en', chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), '?????',
// Not affecting spacing from the beginning and end of a string. ],
['en', ' Hello Abventor! ', ' Hello Abventor! '], 'Illegal/unknown unicode with non default replacement' => [
['pl', ' Drupal Kraków Community', ' Drupal Krakow ', '?', 15], 'en', chr(0xF8) . chr(0x80) . chr(0x80) . chr(0x80) . chr(0x80), '-----', '-',
// Keep many spaces between words. ],
['en', 'Too many spaces between words !', 'Too many spaces between words !'], 'Contains Illegal/unknown unicode' => [
'en', 'Hel' . chr(0x80) . 'o World', 'Hel?o World',
],
'Illegal/unknown unicode at end' => [
'en', 'Hell' . chr(0x80) . ' World', 'Hell? World',
],
'Non default replacement' => [
'en', chr(0x80) . 'ello World', '_ello World', '_',
],
'Keep the original question marks' => [
'en', chr(0xF8) . '?' . chr(0x80), '???',
],
'Keep the original question marks when non default replacement' => [
'en', chr(0x80) . 'ello ? World?', '_ello ? World?', '_',
],
'Keep the original question marks in some other language' => [
'pl', 'aąeę' . chr(0x80) . 'oółżźz ?', 'aaee?oolzzz ?',
],
'Non-US-ASCII replacement in English' => [
'en', chr(0x80) . 'ello World?', 'Oello World?', 'Ö',
],
'Non-US-ASCII replacement in some other language' => [
'pl', chr(0x80) . 'óóść', 'ooosc', 'ó',
],
'Ensure question marks are replaced when max length used' => [
'en', chr(0x80) . 'ello ? World?', '_ello ?', '_', 7,
],
'Empty replacement' => [
'en', chr(0x80) . 'ello World' . chr(0xF8), 'ello World', '',
],
'Not affecting spacing from the beginning and end of a string' => [
'en', ' Hello Abventor! ', ' Hello Abventor! ',
],
'Not affecting spacing from the beginning and end of a string when max length used' => [
'pl', ' Drupal Kraków Community', ' Drupal Krakow ', '?', 15,
],
'Keep many spaces between words' => [
'en', 'Too many spaces between words !', 'Too many spaces between words !',
],
]; ];
// cSpell:enable // cSpell:enable
} }