protected function HalEntityNormalizationTrait::assertNormalizationEdgeCases in Drupal 9
Same name and namespace in other branches
- 8 core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php \Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait::assertNormalizationEdgeCases()
File
- core/modules/hal/tests/src/Functional/EntityResource/HalEntityNormalizationTrait.php, line 76
Class
- HalEntityNormalizationTrait
- Trait for EntityResourceTestBase subclasses testing formats using HAL.
Namespace
Drupal\Tests\hal\Functional\EntityResource
Code
protected function assertNormalizationEdgeCases($method, Url $url, array $request_options) {
if ($this->entity
->getEntityType()
->hasKey('bundle')) {
$normalization = $this
->getNormalizedPostEntity();
$normalization['_links']['type'] = Url::fromUri('base:rest/type/' . static::$entityTypeId . '/bad_bundle_name');
$request_options[RequestOptions::BODY] = $this->serializer
->encode($normalization, static::$format);
$response = $this
->request($method, $url, $request_options);
$this
->assertResourceErrorResponse(422, 'No entity type(s) specified', $response);
unset($normalization['_links']['type']);
$request_options[RequestOptions::BODY] = $this->serializer
->encode($normalization, static::$format);
$response = $this
->request($method, $url, $request_options);
$this
->assertResourceErrorResponse(422, 'The type link relation must be specified.', $response);
}
}