function JsonApiDocumentTopLevelNormalizerTest::testNormalizeException
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeException()
- 8.9.x core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeException()
- 11.x core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::testNormalizeException()
@covers ::normalize
File
-
core/
modules/ jsonapi/ tests/ src/ Kernel/ Normalizer/ JsonApiDocumentTopLevelNormalizerTest.php, line 406
Class
- JsonApiDocumentTopLevelNormalizerTest
- @coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi @group #slow
Namespace
Drupal\Tests\jsonapi\Kernel\NormalizerCode
public function testNormalizeException() : void {
$normalized = $this->container
->get('jsonapi.serializer')
->normalize(new JsonApiDocumentTopLevel(new ErrorCollection([
new BadRequestHttpException('Lorem'),
]), new NullIncludedData(), new LinkCollection([])), 'api_json', [])
->getNormalization();
$this->assertNotEmpty($normalized['errors']);
$this->assertArrayNotHasKey('data', $normalized);
$this->assertEquals(400, $normalized['errors'][0]['status']);
$this->assertEquals('Lorem', $normalized['errors'][0]['detail']);
$this->assertEquals([
'info' => [
'href' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1',
],
'via' => [
'href' => 'http://localhost/',
],
], $normalized['errors'][0]['links']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.