protected function QueryTestBase::query in GraphQL 8
Same name and namespace in other branches
- 8.2 src/Tests/QueryTestBase.php \Drupal\graphql\Tests\QueryTestBase::query()
Helper function to issue a HTTP request with simpletest's cURL. &
Parameters
$query:
array $variables:
string|null $operation:
Return value
string The content returned from the request. The content returned from the request.
1 call to QueryTestBase::query()
- EntityQueryTest::testSingleNodeQuery in src/
Tests/ EntityQueryTest.php - Helper function to issue a HTTP request with simpletest's cURL.
File
- src/
Tests/ QueryTestBase.php, line 49
Class
- QueryTestBase
- Test helper class for GraphQL query tests.
Namespace
Drupal\graphql\TestsCode
protected function query($query, array $variables = NULL, $operation = NULL) {
$body = [
'query' => $query,
'variables' => $variables,
'operation' => $operation,
];
$options = [
CURLOPT_HTTPGET => FALSE,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => json_encode($body),
CURLOPT_URL => $this
->buildUrl($this->queryUrl),
CURLOPT_NOBODY => FALSE,
];
$body = $this
->curlExec($options);
$headers = $this
->drupalGetHeaders();
$this
->verbose('<hr />Code: ' . curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE) . '<hr />Response headers: ' . nl2br(print_r($headers, TRUE)) . '<hr />Response body: ' . $body);
return $body;
}