66use PHPUnit \Framework \TestCase ;
77
88class CommentsClientAnalyzeTest extends TestCase {
9- /** @var CommentsResponse */
10- protected static $ response ;
9+ protected static CommentsResponse $ response ;
1110
11+ /**
12+ * @throws CommentsException
13+ */
1214 public static function setUpBeforeClass (): void {
1315 $ commentsClient = new CommentsClient ($ _ENV ['PERSPECTIVE_API_TOKEN ' ]);
1416 $ commentsClient ->comment (['text ' => 'What kind of idiot name is foo? Sorry, I like your name. ' ]);
@@ -32,7 +34,7 @@ public function testAttributeScores(): void {
3234
3335 $ this ->assertIsArray ($ attributeScores );
3436 $ this ->arrayHasKey ('TOXICITY ' );
35- $ this ->assertGreaterThan (0.8 , $ attributeScores ['TOXICITY ' ]['summaryScore ' ]['value ' ]);
37+ $ this ->assertGreaterThan (0.7 , $ attributeScores ['TOXICITY ' ]['summaryScore ' ]['value ' ]);
3638 }
3739
3840 public function testLanguages () {
@@ -50,9 +52,10 @@ public function testClientToken() {
5052
5153 public function testCommentsException () {
5254 $ this ->expectException (CommentsException::class);
53- $ this ->expectExceptionMessage ('The request is missing a valid API key. ' );
55+ $ this ->expectExceptionMessage ('API key not valid. Please pass a valid API key. ' );
5456
55- $ commentsClient = new CommentsClient ('' );
57+ $ commentsClient = new CommentsClient ('invalid key ' );
58+ $ commentsClient ->comment (['text ' => 'What kind of idiot name is foo? Sorry, I like your name. ' ]);
5659 $ commentsClient ->analyze ();
5760 }
5861}
0 commit comments