public function RequestTest::testRequests in OpenAPI 8
Tests OpenAPI requests.
@dataProvider providerRequestTypes
File
- tests/
src/ Functional/ RequestTest.php, line 134
Class
- RequestTest
- Tests requests OpenAPI routes.
Namespace
Drupal\Tests\openapi\FunctionalCode
public function testRequests($api_module, $options = []) {
if ($api_module == 'rest') {
// 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();
}
if ($api_module == 'jsonapi') {
// @todo Add JSON API to $modules
// Currently this will not work because the new bundles are not picked
// up in \Drupal\jsonapi\Routing\Routes::routes().
$this->container
->get('module_installer')
->install([
'jsonapi',
]);
}
$this
->requestOpenApiJson($api_module, $options);
}