Skip to content

Commit

Permalink
update generation script and map/regex files
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
aaronpk committed Nov 30, 2017
1 parent 80a0037 commit ffe98c0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
22 changes: 17 additions & 5 deletions build/generate-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@
$map = [];

foreach($emoji_data as $emoji) {
$map[$emoji['unified']] = $emoji['short_name'];
foreach($emoji['variations'] as $var) {
$map[$var] = $emoji['short_name'];
$short_name = $emoji['short_name'];

// Slack changed flag-de shortname to de, but we still want to keep flag-de
// Most of the flag emojis are still flag-*, they only changed some of them
if(isset($emoji['short_names']) && in_array('flag-'.$short_name, $emoji['short_names'])) {
$short_name = 'flag-' . $short_name;
}

$map[$emoji['unified']] = $short_name;

if(isset($emoji['variations'])) {
foreach($emoji['variations'] as $var) {
$map[$var] = $short_name;
}
}
if(array_key_exists('skin_variations', $emoji)) {

if(isset($emoji['skin_variations'])) {
foreach($emoji['skin_variations'] as $key=>$var) {
$map[$emoji['unified'] . '-' . $key] = $emoji['short_name'];
$map[$var['unified']] = $short_name;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/map.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/regexp.json

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion tests/EmojiDetectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testDetectSymbolWithModifier() {
}

public function testDetectCharacterSymbol() {
$string = '';
$string = '';
$emoji = Emoji\detect_emoji($string);
$this->assertEquals(1, count($emoji));
$this->assertEquals('tm', $emoji[0]['short_name']);
Expand All @@ -87,4 +87,20 @@ public function testDetectInText() {
$this->assertEquals('tada', $emoji[0]['short_name']);
}

public function testDetectGenderModifier() {
// Added in June 2017 http://www.unicode.org/Public/emoji/5.0/emoji-test.txt
$string = 'guardswoman 💂‍♀️';
$emoji = Emoji\detect_emoji($string);
$this->assertEquals(1, count($emoji));
$this->assertEquals('female-guard', $emoji[0]['short_name']);
}

public function testDetectGenderAndSkinToneModifier() {
// Added in June 2017 http://www.unicode.org/Public/emoji/5.0/emoji-test.txt
$string = 'guardswoman 💂🏼‍♀️';
$emoji = Emoji\detect_emoji($string);
$this->assertEquals(1, count($emoji));
$this->assertEquals('female-guard', $emoji[0]['short_name']);
}

}

0 comments on commit ffe98c0

Please sign in to comment.