public function RequestTestRest::testRequests in OpenAPI for REST 8.2
Tests OpenAPI requests.
@dataProvider providerRequestTypes
File
- tests/
src/ Functional/ RequestTestRest.php, line 44
Class
- RequestTestRest
- REST tests for requests on OpenAPI routes.
Namespace
Drupal\Tests\openapi_rest\FunctionalCode
public function testRequests($api_module, $options = []) {
// Enable all the entity types each request to make sure $options is
// respected for all parts of the spec.
$enable_entity_types = [
'openapi_test_entity' => [
'GET',
'POST',
'PATCH',
'DELETE',
],
'openapi_test_entity_type' => [
'GET',
],
'user' => [
'GET',
],
'taxonomy_term' => [
'GET',
'POST',
'PATCH',
'DELETE',
],
'taxonomy_vocabulary' => [
'GET',
],
];
foreach ($enable_entity_types as $entity_type_id => $methods) {
foreach ($methods as $method) {
$this
->enableRestService("entity:{$entity_type_id}", $method, 'json');
if ($entity_type_id === 'openapi_test_entity') {
$this
->enableRestService("entity:{$entity_type_id}", $method, 'hal_json');
}
}
}
$this->container
->get('router.builder')
->rebuild();
$this
->requestOpenApiJson($api_module, $options);
}