Fix code style

This commit is contained in:
Art4 2025-02-17 10:01:25 +00:00
parent 4f3349f6db
commit a94bead5f6

View file

@ -38,13 +38,13 @@ class SmiliesTest extends FixtureTestCase
return [
/** @see https://github.com/friendica/friendica/pull/6933 */
'bug-6933-1' => [
'data' => '<code>/</code>',
'smilies' => ['texts' => [], 'icons' => []],
'data' => '<code>/</code>',
'smilies' => ['texts' => [], 'icons' => []],
'expected' => '<code>/</code>',
],
'bug-6933-2' => [
'data' => '<code>code</code>',
'smilies' => ['texts' => [], 'icons' => []],
'data' => '<code>code</code>',
'smilies' => ['texts' => [], 'icons' => []],
'expected' => '<code>code</code>',
],
];
@ -72,56 +72,56 @@ class SmiliesTest extends FixtureTestCase
return [
'emoji' => [
'expected' => true,
'body' => '👀',
'body' => '👀',
],
'emojis' => [
'expected' => true,
'body' => '👀🤷',
'body' => '👀🤷',
],
'emoji+whitespace' => [
'expected' => true,
'body' => ' 👀 ',
'body' => ' 👀 ',
],
'empty' => [
'expected' => false,
'body' => '',
'body' => '',
],
'whitespace' => [
'expected' => false,
'body' => '
'body' => '
',
],
'emoji+ASCII' => [
'expected' => false,
'body' => '🤷a',
'body' => '🤷a',
],
'HTML entity whitespace' => [
'expected' => false,
'body' => '&nbsp;',
'body' => '&nbsp;',
],
'HTML entity else' => [
'expected' => false,
'body' => '&deg;',
'body' => '&deg;',
],
'emojis+HTML whitespace' => [
'expected' => true,
'body' => '👀&nbsp;🤷',
'body' => '👀&nbsp;🤷',
],
'emojis+HTML else' => [
'expected' => false,
'body' => '👀&lt;🤷',
'body' => '👀&lt;🤷',
],
'zwj' => [
'expected' => true,
'body' => '👨‍👨‍👧‍',
'body' => '👨‍👨‍👧‍',
],
'zwj+whitespace' => [
'expected' => true,
'body' => ' 👨‍👨‍👧‍ ',
'body' => ' 👨‍👨‍👧‍ ',
],
'zwj+HTML whitespace' => [
'expected' => true,
'body' => '&nbsp;👨‍👨‍👧‍&nbsp;',
'body' => '&nbsp;👨‍👨‍👧‍&nbsp;',
],
];
}
@ -139,59 +139,59 @@ class SmiliesTest extends FixtureTestCase
$data = [
'simple-1' => [
'expected' => 'alt=":-p"',
'body' => ':-p',
'body' => ':-p',
],
'simple-2' => [
'expected' => 'alt=":-p"',
'body' => ' :-p ',
'body' => ' :-p ',
],
'word-boundary-1' => [
'expected' => ':-pppp',
'body' => ':-pppp',
'body' => ':-pppp',
],
'word-boundary-2' => [
'expected' => '~friendicaca',
'body' => '~friendicaca',
'body' => '~friendicaca',
],
'symbol-boundary-1' => [
'expected' => 'alt=":-p"',
'body' => '(:-p)',
'body' => '(:-p)',
],
'hearts-1' => [
'expected' => '❤ (❤) ❤',
'body' => '&lt;3 (&lt;3) &lt;3',
'body' => '&lt;3 (&lt;3) &lt;3',
],
'hearts-8' => [
'expected' => '(❤❤❤❤❤❤❤❤)',
'body' => '(&lt;33333333)',
'body' => '(&lt;33333333)',
],
'no-hearts-1' => [
'expected' => '(&lt;30)',
'body' => '(&lt;30)',
'body' => '(&lt;30)',
],
'no-hearts-2' => [
'expected' => '(3&lt;33)',
'body' => '(3&lt;33)',
'body' => '(3&lt;33)',
],
'space' => [
'expected' => 'alt="smiley-heart"',
'body' => ':smiley heart 333:',
'body' => ':smiley heart 333:',
],
'substitution-1' => [
'expected' => '&#x1F525;',
'body' => '⽕',
'body' => '⽕',
],
'substitution-2' => [
'expected' => '&#x1F917;',
'body' => ':hugging face:',
'body' => ':hugging face:',
],
'substitution-3' => [
'expected' => '&#x1F92D;',
'body' => ':face with hand over mouth:',
'body' => ':face with hand over mouth:',
],
'mixed' => [
'expected' => '&#x1F525; &#x1F92D; invalid:hugging face: &#x1F917;',
'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 $suffix) {
$no_smile = ($prefix !== '' && ctype_alnum($prefix)) || ($suffix !== '' && ctype_alnum($suffix));
$s = $prefix . $emoji . $suffix;
$data[] = [
$s = $prefix . $emoji . $suffix;
$data[] = [
'expected' => $no_smile ? $s : 'alt="' . $emoji . '"',
'body' => $s,
'body' => $s,
];
}
}
@ -223,58 +223,58 @@ class SmiliesTest extends FixtureTestCase
{
return [
'symbols' => [
'expected' => ['p', 'heart', 'embarrassed', 'kiss'],
'body' => ':-p &lt;3 ":-[:-"',
'expected' => ['p', 'heart', 'embarrassed', 'kiss'],
'body' => ':-p &lt;3 ":-[:-"',
'normalized' => ':p: :heart: ":embarrassed::kiss:',
],
'single-smiley' => [
'expected' => ['like'],
'body' => ':like',
'expected' => ['like'],
'body' => ':like',
'normalized' => ':like:',
],
'multiple-smilies' => [
'expected' => ['like', 'dislike'],
'body' => ':like :dislike',
'expected' => ['like', 'dislike'],
'body' => ':like :dislike',
'normalized' => ':like: :dislike:',
],
'nosmile' => [
'expected' => [],
'body' => '[nosmile] :like :like',
'expected' => [],
'body' => '[nosmile] :like :like',
'normalized' => '[nosmile] :like :like'
],
'in-code' => [
'expected' => [],
'body' => '[code]:like :like :like[/code]',
'expected' => [],
'body' => '[code]:like :like :like[/code]',
'normalized' => '[code]:like :like :like[/code]'
],
'~friendica' => [
'expected' => ['friendica'],
'body' => '~friendica',
'expected' => ['friendica'],
'body' => '~friendica',
'normalized' => ':friendica:'
],
'space' => [
'expected' => ['smileyheart333'],
'body' => ':smiley heart 333:',
'expected' => ['smileyheart333'],
'body' => ':smiley heart 333:',
'normalized' => ':smileyheart333:'
],
'substitution-1' => [
'expected' => [],
'body' => '⽕',
'expected' => [],
'body' => '⽕',
'normalized' => '&#x1F525;',
],
'substitution-2' => [
'expected' => [],
'body' => ':hugging face:',
'expected' => [],
'body' => ':hugging face:',
'normalized' => '&#x1F917;',
],
'substitution-3' => [
'expected' => [],
'body' => ':face with hand over mouth:',
'expected' => [],
'body' => ':face with hand over mouth:',
'normalized' => '&#x1F92D;',
],
'mixed' => [
'expected' => [],
'body' => '⽕ :face with hand over mouth: invalid:hugging face: :hugging face:',
'expected' => [],
'body' => '⽕ :face with hand over mouth: invalid:hugging face: :hugging face:',
'normalized' => '&#x1F525; &#x1F92D; invalid:hugging face: &#x1F917;',
],
];
@ -286,7 +286,7 @@ class SmiliesTest extends FixtureTestCase
public function testExtractUsedSmilies(array $expected, string $body, string $normalized): void
{
$extracted = Smilies::extractUsedSmilies($body, $converted);
$expected = array_fill_keys($expected, true);
$expected = array_fill_keys($expected, true);
$this->assertEquals($normalized, $converted);
foreach (array_keys($extracted) as $shortcode) {
$this->assertArrayHasKey($shortcode, $expected);