public function ApiRequestTest::testZoomApiConnection in Zoom API 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/ApiRequestTest.php \Drupal\Tests\zoomapi\Functional\ApiRequestTest::testZoomApiConnection()
Will fail, but that's ok.
File
- tests/
src/ Functional/ ApiRequestTest.php, line 57
Class
- ApiRequestTest
- API request tests.
Namespace
Drupal\Tests\zoomapi\FunctionalCode
public function testZoomApiConnection() {
// Create test keys.
$this
->createTestKey('test_zoomapi_key', 'authentication', 'config');
$this
->createTestKey('test_zoomapi_secret', 'authentication', 'config');
// Update Zoomapi config.
$this
->drupalGet(Url::fromRoute('zoomapi.settings'));
$edit = [
'base_uri' => 'https://api.zoom.us/v2',
'api_key' => 'test_zoomapi_key',
'api_secret' => 'test_zoomapi_secret',
];
$this
->drupalPostForm(NULL, $edit, 'Save configuration');
$url = Url::fromRoute('zoomapi.webhooks')
->setAbsolute()
->toString();
// Post to the webhook controller.
$client = \Drupal::service('zoomapi.client');
try {
$client
->request('GET', '/users');
} catch (RequestException $exception) {
// We are expecting failure.
$message = $exception
->getMessage();
$this
->assertStringContainsString('401 Unauthorized', $message, '401 Unauthorized was returned.');
$this
->assertStringContainsString('Client error', $message, 'Asserting client error exists.');
}
}