RequestHelperTrait.php in Simple OAuth (OAuth2) & OpenID Connect 8.4
File
tests/src/Functional/RequestHelperTrait.php
View source
<?php
namespace Drupal\Tests\simple_oauth\Functional;
use Drupal\Core\Url;
use GuzzleHttp\RequestOptions;
trait RequestHelperTrait {
protected function post(Url $url, array $data, array $options = []) {
$post_url = $this
->getAbsoluteUrl($url
->toString());
$session = $this
->getSession();
$session
->setCookie('SIMPLETEST_USER_AGENT', drupal_generate_test_ua($this->databasePrefix));
return $this
->getHttpClient()
->request('POST', $post_url, [
'form_params' => $data,
'http_errors' => FALSE,
] + $options);
}
protected function get(Url $url, $options = []) {
$options += [
RequestOptions::HTTP_ERRORS => FALSE,
];
$session = $this
->getSession();
$get_url = $this
->getAbsoluteUrl($url
->toString());
$session
->setCookie('SIMPLETEST_USER_AGENT', drupal_generate_test_ua($this->databasePrefix));
return $this
->getHttpClient()
->get($get_url, $options);
}
}