Skip to content

Commit 65b213c

Browse files
committed
Adds test case for invalid api key.
1 parent b8f86e1 commit 65b213c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/Integration/SDKTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public function setUp()
1515
$this->sdk = new SDK(['api_key' => $this->config['api_key'], 'summary_length' => 5]);
1616
}
1717

18+
public function testApiKeyIsInvalid()
19+
{
20+
$sdk = $this->sdk = new SDK(['api_key' => 'INVALID1J3243N090', 'summary_length' => 5]);
21+
$response = $sdk->summarizeText($this->getTextToSummarize());
22+
23+
$this->assertInstanceOf('stdClass', $response);
24+
$this->assertObjectHasAttribute('sm_api_error', $response);
25+
$this->assertObjectHasAttribute('sm_api_message', $response);
26+
$this->assertEquals(1, $response->sm_api_error);
27+
$this->assertEquals('INVALID API KEY', $response->sm_api_message);
28+
}
29+
1830
public function testSummarizesExpectedText()
1931
{
2032
$response = $this->sdk->summarizeText($this->getTextToSummarize());

0 commit comments

Comments
 (0)