diff --git a/tests/src/Content/SmiliesTest.php b/tests/src/Content/SmiliesTest.php index 2882eeb8d5..69236efe2d 100644 --- a/tests/src/Content/SmiliesTest.php +++ b/tests/src/Content/SmiliesTest.php @@ -38,13 +38,13 @@ class SmiliesTest extends FixtureTestCase return [ /** @see https://github.com/friendica/friendica/pull/6933 */ 'bug-6933-1' => [ - 'data' => '/', - 'smilies' => ['texts' => [], 'icons' => []], + 'data' => '/', + 'smilies' => ['texts' => [], 'icons' => []], 'expected' => '/', ], 'bug-6933-2' => [ - 'data' => 'code', - 'smilies' => ['texts' => [], 'icons' => []], + 'data' => 'code', + 'smilies' => ['texts' => [], 'icons' => []], 'expected' => '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);