protected function EndpointAccessibilityRequirement::testContentViewEndpoint in Acquia Content Hub 8
Test the content view endpoint.
1 call to EndpointAccessibilityRequirement::testContentViewEndpoint()
- EndpointAccessibilityRequirement::verify in acquia_contenthub_diagnostic/
src/ Plugin/ ContentHubRequirement/ EndpointAccessibilityRequirement.php - Verify the accessibility of the content hub endpoints.
File
- acquia_contenthub_diagnostic/
src/ Plugin/ ContentHubRequirement/ EndpointAccessibilityRequirement.php, line 104
Class
- EndpointAccessibilityRequirement
- Defines an endpoint accessibility requirement.
Namespace
Drupal\acquia_contenthub_diagnostic\Plugin\ContentHubRequirementCode
protected function testContentViewEndpoint() {
$endpoint_name = 'Content View Endpoint';
$test_nid = $this
->getTestNid();
if ($test_nid) {
$endpoint_url = $this->domain . '/acquia-contenthub/display/node/' . $test_nid . '/default';
$authorization = $this
->getAuthorizationHeader($endpoint_url);
// HTTP Client only accepts Guzzle Requests.
$request = new GuzzleRequest('GET', $endpoint_url, [
'authorization' => $authorization,
]);
$client = \Drupal::httpClient();
$response = $client
->send($request, static::REQUEST_OPTIONS);
$status_code = $response
->getStatusCode();
$this->description .= $this
->parseStatusCode($status_code, $endpoint_name, $endpoint_url);
}
else {
$endpoint_url = '/acquia-contenthub/display/node/{entity_id}/default';
$this->description .= $this
->t("@endpoint_name (@endpoint_url) requires a node to exist on the site in order to test. Create a node and try again.", [
'@endpoint_name' => $endpoint_name,
'@endpoint_url' => $endpoint_url,
]);
}
}