mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-08 11:14:31 +02:00
Fix code style
This commit is contained in:
parent
4f3349f6db
commit
a94bead5f6
1 changed files with 57 additions and 57 deletions
|
@ -38,13 +38,13 @@ class SmiliesTest extends FixtureTestCase
|
||||||
return [
|
return [
|
||||||
/** @see https://github.com/friendica/friendica/pull/6933 */
|
/** @see https://github.com/friendica/friendica/pull/6933 */
|
||||||
'bug-6933-1' => [
|
'bug-6933-1' => [
|
||||||
'data' => '<code>/</code>',
|
'data' => '<code>/</code>',
|
||||||
'smilies' => ['texts' => [], 'icons' => []],
|
'smilies' => ['texts' => [], 'icons' => []],
|
||||||
'expected' => '<code>/</code>',
|
'expected' => '<code>/</code>',
|
||||||
],
|
],
|
||||||
'bug-6933-2' => [
|
'bug-6933-2' => [
|
||||||
'data' => '<code>code</code>',
|
'data' => '<code>code</code>',
|
||||||
'smilies' => ['texts' => [], 'icons' => []],
|
'smilies' => ['texts' => [], 'icons' => []],
|
||||||
'expected' => '<code>code</code>',
|
'expected' => '<code>code</code>',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -72,56 +72,56 @@ class SmiliesTest extends FixtureTestCase
|
||||||
return [
|
return [
|
||||||
'emoji' => [
|
'emoji' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => '👀',
|
'body' => '👀',
|
||||||
],
|
],
|
||||||
'emojis' => [
|
'emojis' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => '👀🤷',
|
'body' => '👀🤷',
|
||||||
],
|
],
|
||||||
'emoji+whitespace' => [
|
'emoji+whitespace' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => ' 👀 ',
|
'body' => ' 👀 ',
|
||||||
],
|
],
|
||||||
'empty' => [
|
'empty' => [
|
||||||
'expected' => false,
|
'expected' => false,
|
||||||
'body' => '',
|
'body' => '',
|
||||||
],
|
],
|
||||||
'whitespace' => [
|
'whitespace' => [
|
||||||
'expected' => false,
|
'expected' => false,
|
||||||
'body' => '
|
'body' => '
|
||||||
',
|
',
|
||||||
],
|
],
|
||||||
'emoji+ASCII' => [
|
'emoji+ASCII' => [
|
||||||
'expected' => false,
|
'expected' => false,
|
||||||
'body' => '🤷a',
|
'body' => '🤷a',
|
||||||
],
|
],
|
||||||
'HTML entity whitespace' => [
|
'HTML entity whitespace' => [
|
||||||
'expected' => false,
|
'expected' => false,
|
||||||
'body' => ' ',
|
'body' => ' ',
|
||||||
],
|
],
|
||||||
'HTML entity else' => [
|
'HTML entity else' => [
|
||||||
'expected' => false,
|
'expected' => false,
|
||||||
'body' => '°',
|
'body' => '°',
|
||||||
],
|
],
|
||||||
'emojis+HTML whitespace' => [
|
'emojis+HTML whitespace' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => '👀 🤷',
|
'body' => '👀 🤷',
|
||||||
],
|
],
|
||||||
'emojis+HTML else' => [
|
'emojis+HTML else' => [
|
||||||
'expected' => false,
|
'expected' => false,
|
||||||
'body' => '👀<🤷',
|
'body' => '👀<🤷',
|
||||||
],
|
],
|
||||||
'zwj' => [
|
'zwj' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => '👨👨👧',
|
'body' => '👨👨👧',
|
||||||
],
|
],
|
||||||
'zwj+whitespace' => [
|
'zwj+whitespace' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => ' 👨👨👧 ',
|
'body' => ' 👨👨👧 ',
|
||||||
],
|
],
|
||||||
'zwj+HTML whitespace' => [
|
'zwj+HTML whitespace' => [
|
||||||
'expected' => true,
|
'expected' => true,
|
||||||
'body' => ' 👨👨👧 ',
|
'body' => ' 👨👨👧 ',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -139,59 +139,59 @@ class SmiliesTest extends FixtureTestCase
|
||||||
$data = [
|
$data = [
|
||||||
'simple-1' => [
|
'simple-1' => [
|
||||||
'expected' => 'alt=":-p"',
|
'expected' => 'alt=":-p"',
|
||||||
'body' => ':-p',
|
'body' => ':-p',
|
||||||
],
|
],
|
||||||
'simple-2' => [
|
'simple-2' => [
|
||||||
'expected' => 'alt=":-p"',
|
'expected' => 'alt=":-p"',
|
||||||
'body' => ' :-p ',
|
'body' => ' :-p ',
|
||||||
],
|
],
|
||||||
'word-boundary-1' => [
|
'word-boundary-1' => [
|
||||||
'expected' => ':-pppp',
|
'expected' => ':-pppp',
|
||||||
'body' => ':-pppp',
|
'body' => ':-pppp',
|
||||||
],
|
],
|
||||||
'word-boundary-2' => [
|
'word-boundary-2' => [
|
||||||
'expected' => '~friendicaca',
|
'expected' => '~friendicaca',
|
||||||
'body' => '~friendicaca',
|
'body' => '~friendicaca',
|
||||||
],
|
],
|
||||||
'symbol-boundary-1' => [
|
'symbol-boundary-1' => [
|
||||||
'expected' => 'alt=":-p"',
|
'expected' => 'alt=":-p"',
|
||||||
'body' => '(:-p)',
|
'body' => '(:-p)',
|
||||||
],
|
],
|
||||||
'hearts-1' => [
|
'hearts-1' => [
|
||||||
'expected' => '❤ (❤) ❤',
|
'expected' => '❤ (❤) ❤',
|
||||||
'body' => '<3 (<3) <3',
|
'body' => '<3 (<3) <3',
|
||||||
],
|
],
|
||||||
'hearts-8' => [
|
'hearts-8' => [
|
||||||
'expected' => '(❤❤❤❤❤❤❤❤)',
|
'expected' => '(❤❤❤❤❤❤❤❤)',
|
||||||
'body' => '(<33333333)',
|
'body' => '(<33333333)',
|
||||||
],
|
],
|
||||||
'no-hearts-1' => [
|
'no-hearts-1' => [
|
||||||
'expected' => '(<30)',
|
'expected' => '(<30)',
|
||||||
'body' => '(<30)',
|
'body' => '(<30)',
|
||||||
],
|
],
|
||||||
'no-hearts-2' => [
|
'no-hearts-2' => [
|
||||||
'expected' => '(3<33)',
|
'expected' => '(3<33)',
|
||||||
'body' => '(3<33)',
|
'body' => '(3<33)',
|
||||||
],
|
],
|
||||||
'space' => [
|
'space' => [
|
||||||
'expected' => 'alt="smiley-heart"',
|
'expected' => 'alt="smiley-heart"',
|
||||||
'body' => ':smiley heart 333:',
|
'body' => ':smiley heart 333:',
|
||||||
],
|
],
|
||||||
'substitution-1' => [
|
'substitution-1' => [
|
||||||
'expected' => '🔥',
|
'expected' => '🔥',
|
||||||
'body' => '⽕',
|
'body' => '⽕',
|
||||||
],
|
],
|
||||||
'substitution-2' => [
|
'substitution-2' => [
|
||||||
'expected' => '🤗',
|
'expected' => '🤗',
|
||||||
'body' => ':hugging face:',
|
'body' => ':hugging face:',
|
||||||
],
|
],
|
||||||
'substitution-3' => [
|
'substitution-3' => [
|
||||||
'expected' => '🤭',
|
'expected' => '🤭',
|
||||||
'body' => ':face with hand over mouth:',
|
'body' => ':face with hand over mouth:',
|
||||||
],
|
],
|
||||||
'mixed' => [
|
'mixed' => [
|
||||||
'expected' => '🔥 🤭 invalid:hugging face: 🤗',
|
'expected' => '🔥 🤭 invalid:hugging face: 🤗',
|
||||||
'body' => '⽕ :face with hand over mouth: invalid:hugging face: :hugging face:',
|
'body' => '⽕ :face with hand over mouth: invalid:hugging face: :hugging face:',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -199,10 +199,10 @@ class SmiliesTest extends FixtureTestCase
|
||||||
foreach (['A', '_', ':', '-'] as $prefix) {
|
foreach (['A', '_', ':', '-'] as $prefix) {
|
||||||
foreach (['', ' ', 'A', ':', '-'] as $suffix) {
|
foreach (['', ' ', 'A', ':', '-'] as $suffix) {
|
||||||
$no_smile = ($prefix !== '' && ctype_alnum($prefix)) || ($suffix !== '' && ctype_alnum($suffix));
|
$no_smile = ($prefix !== '' && ctype_alnum($prefix)) || ($suffix !== '' && ctype_alnum($suffix));
|
||||||
$s = $prefix . $emoji . $suffix;
|
$s = $prefix . $emoji . $suffix;
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'expected' => $no_smile ? $s : 'alt="' . $emoji . '"',
|
'expected' => $no_smile ? $s : 'alt="' . $emoji . '"',
|
||||||
'body' => $s,
|
'body' => $s,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,58 +223,58 @@ class SmiliesTest extends FixtureTestCase
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'symbols' => [
|
'symbols' => [
|
||||||
'expected' => ['p', 'heart', 'embarrassed', 'kiss'],
|
'expected' => ['p', 'heart', 'embarrassed', 'kiss'],
|
||||||
'body' => ':-p <3 ":-[:-"',
|
'body' => ':-p <3 ":-[:-"',
|
||||||
'normalized' => ':p: :heart: ":embarrassed::kiss:',
|
'normalized' => ':p: :heart: ":embarrassed::kiss:',
|
||||||
],
|
],
|
||||||
'single-smiley' => [
|
'single-smiley' => [
|
||||||
'expected' => ['like'],
|
'expected' => ['like'],
|
||||||
'body' => ':like',
|
'body' => ':like',
|
||||||
'normalized' => ':like:',
|
'normalized' => ':like:',
|
||||||
],
|
],
|
||||||
'multiple-smilies' => [
|
'multiple-smilies' => [
|
||||||
'expected' => ['like', 'dislike'],
|
'expected' => ['like', 'dislike'],
|
||||||
'body' => ':like :dislike',
|
'body' => ':like :dislike',
|
||||||
'normalized' => ':like: :dislike:',
|
'normalized' => ':like: :dislike:',
|
||||||
],
|
],
|
||||||
'nosmile' => [
|
'nosmile' => [
|
||||||
'expected' => [],
|
'expected' => [],
|
||||||
'body' => '[nosmile] :like :like',
|
'body' => '[nosmile] :like :like',
|
||||||
'normalized' => '[nosmile] :like :like'
|
'normalized' => '[nosmile] :like :like'
|
||||||
],
|
],
|
||||||
'in-code' => [
|
'in-code' => [
|
||||||
'expected' => [],
|
'expected' => [],
|
||||||
'body' => '[code]:like :like :like[/code]',
|
'body' => '[code]:like :like :like[/code]',
|
||||||
'normalized' => '[code]:like :like :like[/code]'
|
'normalized' => '[code]:like :like :like[/code]'
|
||||||
],
|
],
|
||||||
'~friendica' => [
|
'~friendica' => [
|
||||||
'expected' => ['friendica'],
|
'expected' => ['friendica'],
|
||||||
'body' => '~friendica',
|
'body' => '~friendica',
|
||||||
'normalized' => ':friendica:'
|
'normalized' => ':friendica:'
|
||||||
],
|
],
|
||||||
'space' => [
|
'space' => [
|
||||||
'expected' => ['smileyheart333'],
|
'expected' => ['smileyheart333'],
|
||||||
'body' => ':smiley heart 333:',
|
'body' => ':smiley heart 333:',
|
||||||
'normalized' => ':smileyheart333:'
|
'normalized' => ':smileyheart333:'
|
||||||
],
|
],
|
||||||
'substitution-1' => [
|
'substitution-1' => [
|
||||||
'expected' => [],
|
'expected' => [],
|
||||||
'body' => '⽕',
|
'body' => '⽕',
|
||||||
'normalized' => '🔥',
|
'normalized' => '🔥',
|
||||||
],
|
],
|
||||||
'substitution-2' => [
|
'substitution-2' => [
|
||||||
'expected' => [],
|
'expected' => [],
|
||||||
'body' => ':hugging face:',
|
'body' => ':hugging face:',
|
||||||
'normalized' => '🤗',
|
'normalized' => '🤗',
|
||||||
],
|
],
|
||||||
'substitution-3' => [
|
'substitution-3' => [
|
||||||
'expected' => [],
|
'expected' => [],
|
||||||
'body' => ':face with hand over mouth:',
|
'body' => ':face with hand over mouth:',
|
||||||
'normalized' => '🤭',
|
'normalized' => '🤭',
|
||||||
],
|
],
|
||||||
'mixed' => [
|
'mixed' => [
|
||||||
'expected' => [],
|
'expected' => [],
|
||||||
'body' => '⽕ :face with hand over mouth: invalid:hugging face: :hugging face:',
|
'body' => '⽕ :face with hand over mouth: invalid:hugging face: :hugging face:',
|
||||||
'normalized' => '🔥 🤭 invalid:hugging face: 🤗',
|
'normalized' => '🔥 🤭 invalid:hugging face: 🤗',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -286,7 +286,7 @@ class SmiliesTest extends FixtureTestCase
|
||||||
public function testExtractUsedSmilies(array $expected, string $body, string $normalized): void
|
public function testExtractUsedSmilies(array $expected, string $body, string $normalized): void
|
||||||
{
|
{
|
||||||
$extracted = Smilies::extractUsedSmilies($body, $converted);
|
$extracted = Smilies::extractUsedSmilies($body, $converted);
|
||||||
$expected = array_fill_keys($expected, true);
|
$expected = array_fill_keys($expected, true);
|
||||||
$this->assertEquals($normalized, $converted);
|
$this->assertEquals($normalized, $converted);
|
||||||
foreach (array_keys($extracted) as $shortcode) {
|
foreach (array_keys($extracted) as $shortcode) {
|
||||||
$this->assertArrayHasKey($shortcode, $expected);
|
$this->assertArrayHasKey($shortcode, $expected);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue