public function EntityToJsonApiTest::testSerialize in JSON:API 8
@covers ::serialize @covers ::normalize
File
- tests/
src/ Kernel/ EntityToJsonApiTest.php, line 165
Class
- EntityToJsonApiTest
- @coversDefaultClass \Drupal\jsonapi\EntityToJsonApi @group jsonapi @group jsonapi_serializer @group legacy
Namespace
Drupal\Tests\jsonapi\KernelCode
public function testSerialize() {
$entities = [
$this->node,
$this->user,
$this->file,
$this->term1,
// Make sure we also support configuration entities.
$this->vocabulary,
$this->nodeType,
$this->role,
];
array_walk($entities, function ($entity) {
$output = $this->sut
->serialize($entity);
$this
->assertInternalType('string', $output);
$this
->assertJsonApi(Json::decode($output));
$output = $this->sut
->normalize($entity);
$this
->assertInternalType('array', $output);
$this
->assertJsonApi($output);
});
}