mirror of
https://github.com/friendica/friendica
synced 2025-03-03 19:48:26 +00: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 [
|
||||
/** @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' => ' ',
|
||||
'body' => ' ',
|
||||
],
|
||||
'HTML entity else' => [
|
||||
'expected' => false,
|
||||
'body' => '°',
|
||||
'body' => '°',
|
||||
],
|
||||
'emojis+HTML whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => '👀 🤷',
|
||||
'body' => '👀 🤷',
|
||||
],
|
||||
'emojis+HTML else' => [
|
||||
'expected' => false,
|
||||
'body' => '👀<🤷',
|
||||
'body' => '👀<🤷',
|
||||
],
|
||||
'zwj' => [
|
||||
'expected' => true,
|
||||
'body' => '👨👨👧',
|
||||
'body' => '👨👨👧',
|
||||
],
|
||||
'zwj+whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => ' 👨👨👧 ',
|
||||
'body' => ' 👨👨👧 ',
|
||||
],
|
||||
'zwj+HTML whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => ' 👨👨👧 ',
|
||||
'body' => ' 👨👨👧 ',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -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' => '<3 (<3) <3',
|
||||
'body' => '<3 (<3) <3',
|
||||
],
|
||||
'hearts-8' => [
|
||||
'expected' => '(❤❤❤❤❤❤❤❤)',
|
||||
'body' => '(<33333333)',
|
||||
'body' => '(<33333333)',
|
||||
],
|
||||
'no-hearts-1' => [
|
||||
'expected' => '(<30)',
|
||||
'body' => '(<30)',
|
||||
'body' => '(<30)',
|
||||
],
|
||||
'no-hearts-2' => [
|
||||
'expected' => '(3<33)',
|
||||
'body' => '(3<33)',
|
||||
'body' => '(3<33)',
|
||||
],
|
||||
'space' => [
|
||||
'expected' => 'alt="smiley-heart"',
|
||||
'body' => ':smiley heart 333:',
|
||||
'body' => ':smiley heart 333:',
|
||||
],
|
||||
'substitution-1' => [
|
||||
'expected' => '🔥',
|
||||
'body' => '⽕',
|
||||
'body' => '⽕',
|
||||
],
|
||||
'substitution-2' => [
|
||||
'expected' => '🤗',
|
||||
'body' => ':hugging face:',
|
||||
'body' => ':hugging face:',
|
||||
],
|
||||
'substitution-3' => [
|
||||
'expected' => '🤭',
|
||||
'body' => ':face with hand over mouth:',
|
||||
'body' => ':face with hand over mouth:',
|
||||
],
|
||||
'mixed' => [
|
||||
'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 $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 <3 ":-[:-"',
|
||||
'expected' => ['p', 'heart', 'embarrassed', 'kiss'],
|
||||
'body' => ':-p <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' => '🔥',
|
||||
],
|
||||
'substitution-2' => [
|
||||
'expected' => [],
|
||||
'body' => ':hugging face:',
|
||||
'expected' => [],
|
||||
'body' => ':hugging face:',
|
||||
'normalized' => '🤗',
|
||||
],
|
||||
'substitution-3' => [
|
||||
'expected' => [],
|
||||
'body' => ':face with hand over mouth:',
|
||||
'expected' => [],
|
||||
'body' => ':face with hand over mouth:',
|
||||
'normalized' => '🤭',
|
||||
],
|
||||
'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' => '🔥 🤭 invalid:hugging face: 🤗',
|
||||
],
|
||||
];
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue