final class RequestTestJsonapi in OpenAPI for JSON:API 3.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/RequestTestJsonapi.php \Drupal\Tests\openapi_jsonapi\Functional\RequestTestJsonapi
REST tests for requests on OpenAPI routes.
@group openapi_jsonapi
Hierarchy
- class \Drupal\Tests\openapi_jsonapi\Functional\RequestTestJsonapi extends \Drupal\Tests\openapi\Functional\RequestTestBase
Expanded class hierarchy of RequestTestJsonapi
File
- tests/
src/ Functional/ RequestTestJsonapi.php, line 12
Namespace
Drupal\Tests\openapi_jsonapi\FunctionalView source
final class RequestTestJsonapi extends RequestTestBase {
/**
* The API module being tested.
*/
const API_MODULE = 'jsonapi';
/**
* {@inheritdoc}
*/
public static $modules = [
'field',
'filter',
'text',
'taxonomy',
'serialization',
'jsonapi',
'schemata',
'schemata_json_schema',
'openapi',
'openapi_test',
'openapi_jsonapi',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
\Drupal::service('router.builder')
->rebuild();
}
/**
* Tests OpenAPI requests.
*
* @dataProvider providerRequestTypes
*/
public function testRequests($api_module, $options = []) {
$this
->requestOpenApiJson($api_module, $options);
}
/**
* {@inheritdoc}
*/
protected function getRouteBase() {
return ltrim(\Drupal::getContainer()
->getParameter('jsonapi.base_path'), '/');
}
/**
* {@inheritdoc}
*/
protected function assertMimeType(array $actual, array $options = []) {
$this
->assertEquals([
'application/vnd.api+json',
], $actual, "JSON:API root should only contain application/vnd.api+json");
}
/**
* Builds the expectations directory.
*
* @return string
* The expectations directory.
*/
protected function buildExpectationsDirectory() {
return sprintf('%s/expectations/%s', dirname(dirname(__DIR__)), static::API_MODULE);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RequestTestJsonapi:: |
public static | property | ||
RequestTestJsonapi:: |
constant | The API module being tested. | ||
RequestTestJsonapi:: |
protected | function | ||
RequestTestJsonapi:: |
protected | function | Builds the expectations directory. | |
RequestTestJsonapi:: |
protected | function | ||
RequestTestJsonapi:: |
protected | function | ||
RequestTestJsonapi:: |
public | function | Tests OpenAPI requests. |