mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 00:04:27 +02:00
Add unit tests for Smilies::isEmojiPost
- Current implementation is failing tests with emojis including the zero-width-joiner character, encoded on 3 bytes only.
This commit is contained in:
parent
6ed440718d
commit
059a111282
2 changed files with 73 additions and 1 deletions
|
@ -72,4 +72,75 @@ class SmiliesTest extends FixtureTest
|
|||
$output = Smilies::replaceFromArray($text, $smilies);
|
||||
self::assertEquals($expected, $output);
|
||||
}
|
||||
|
||||
public function dataIsEmojiPost(): array
|
||||
{
|
||||
return [
|
||||
'emoji' => [
|
||||
'expected' => true,
|
||||
'body' => '👀',
|
||||
],
|
||||
'emojis' => [
|
||||
'expected' => true,
|
||||
'body' => '👀🤷',
|
||||
],
|
||||
'emoji+whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => ' 👀 ',
|
||||
],
|
||||
'empty' => [
|
||||
'expected' => false,
|
||||
'body' => '',
|
||||
],
|
||||
'whitespace' => [
|
||||
'expected' => false,
|
||||
'body' => '
|
||||
',
|
||||
],
|
||||
'emoji+ASCII' => [
|
||||
'expected' => false,
|
||||
'body' => '🤷a',
|
||||
],
|
||||
'HTML entity whitespace' => [
|
||||
'expected' => false,
|
||||
'body' => ' ',
|
||||
],
|
||||
'HTML entity else' => [
|
||||
'expected' => false,
|
||||
'body' => '°',
|
||||
],
|
||||
'emojis+HTML whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => '👀 🤷',
|
||||
],
|
||||
'emojis+HTML else' => [
|
||||
'expected' => false,
|
||||
'body' => '👀<🤷',
|
||||
],
|
||||
'zwj' => [
|
||||
'expected' => true,
|
||||
'body' => '👨👨👧',
|
||||
],
|
||||
'zwj+whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => ' 👨👨👧 ',
|
||||
],
|
||||
'zwj+HTML whitespace' => [
|
||||
'expected' => true,
|
||||
'body' => ' 👨👨👧 ',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataIsEmojiPost
|
||||
*
|
||||
* @param bool $expected
|
||||
* @param string $body
|
||||
* @return void
|
||||
*/
|
||||
public function testIsEmojiPost(bool $expected, string $body)
|
||||
{
|
||||
$this->assertEquals($expected, Smilies::isEmojiPost($body));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue