Skip to content

Commit

Permalink
Add missing moderation enums. (#178)
Browse files Browse the repository at this point in the history
* fix: add missing moderation category enums

* test: adjust tests for assertions on moderation categories
  • Loading branch information
iBotPeaches authored Aug 3, 2023
1 parent 7c9994f commit 0d64fdb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Enums/Moderations/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ enum Category: string
{
case Hate = 'hate';
case HateThreatening = 'hate/threatening';
case Harassment = 'harassment';
case HarassmentThreatening = 'harassment/threatening';
case SelfHarm = 'self-harm';
case SelfHarmIntent = 'self-harm/intent';
case SelfHarmInstructions = 'self-harm/instructions';
case Sexual = 'sexual';
case SexualMinors = 'sexual/minors';
case Violence = 'violence';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ final class CreateResponseFixture
'categories' => [
'hate' => false,
'hate/threatening' => true,
'harassment' => false,
'harassment/threatening' => false,
'self-harm' => false,
'self-harm/intent' => false,
'self-harm/instructions' => false,
'sexual' => false,
'sexual/minors' => false,
'violence' => true,
Expand All @@ -21,7 +25,11 @@ final class CreateResponseFixture
'category_scores' => [
'hate' => 0.22714105248451233,
'hate/threatening' => 0.4132447838783264,
'harassment' => 0.1602763684674149,
'harassment/threatening' => 0.1602763684674149,
'self-harm' => 0.005232391878962517,
'self-harm/intent' => 0.005134391873962517,
'self-harm/instructions' => 0.005132591874962517,
'sexual' => 0.01407341007143259,
'sexual/minors' => 0.0038522258400917053,
'violence' => 0.9223177433013916,
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/Moderation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ function moderationResource(): array
'categories' => [
'hate' => false,
'hate/threatening' => true,
'harassment' => false,
'harassment/threatening' => false,
'self-harm' => false,
'self-harm/intent' => false,
'self-harm/instructions' => false,
'sexual' => false,
'sexual/minors' => false,
'violence' => true,
Expand All @@ -22,7 +26,11 @@ function moderationResource(): array
'category_scores' => [
'hate' => 0.22714105248451233,
'hate/threatening' => 0.4132447838783264,
'harassment' => 0.1602763684674149,
'harassment/threatening' => 0.1602763684674149,
'self-harm' => 0.005232391878962517,
'self-harm/intent' => 0.005134391873962517,
'self-harm/instructions' => 0.005132591874962517,
'sexual' => 0.01407341007143259,
'sexual/minors' => 0.0038522258400917053,
'violence' => 0.9223177433013916,
Expand Down
7 changes: 6 additions & 1 deletion tests/Resources/Moderations.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@

expect($result->results[0])
->flagged->toBeTrue()
->categories->toHaveCount(7)
->categories->toHaveCount(11)
->each->toBeInstanceOf(CreateResponseCategory::class);

expect($result->results[0]->categories[Category::Hate->value])
->category->toBe(Category::Hate)
->violated->toBe(false)
->score->toBe(0.22714105248451233);

expect($result->results[0]->categories[Category::Violence->value])
->category->toBe(Category::Violence)
->violated->toBe(true)
->score->toBe(0.9223177433013916);
});
2 changes: 1 addition & 1 deletion tests/Responses/Moderations/CreateResponseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

expect($result)
->flagged->toBeTrue()
->categories->toHaveCount(7)
->categories->toHaveCount(11)
->each->toBeInstanceOf(CreateResponseCategory::class);
});

Expand Down

0 comments on commit 0d64fdb

Please sign in to comment.