public function EntityToJsonApiTest::testSerialize in JSON:API Extras 8.2
Same name and namespace in other branches
- 8.3 tests/src/Kernel/EntityToJsonApiTest.php \Drupal\Tests\jsonapi_extras\Kernel\EntityToJsonApiTest::testSerialize()
@covers ::serialize @covers ::normalize
File
- tests/
src/ Kernel/ EntityToJsonApiTest.php, line 173
Class
- EntityToJsonApiTest
- @coversDefaultClass \Drupal\jsonapi_extras\EntityToJsonApi @group jsonapi @group jsonapi_serializer @group legacy
Namespace
Drupal\Tests\jsonapi_extras\KernelCode
public function testSerialize() {
$entities = [
[
$this->node,
[
'field_tags',
],
[
[
'type' => 'taxonomy_term--tags',
'id' => $this->term1
->uuid(),
'attributes' => [
'tid' => (int) $this->term1
->id(),
'name' => $this->term1
->label(),
],
],
[
'type' => 'taxonomy_term--tags',
'id' => $this->term2
->uuid(),
'attributes' => [
'tid' => (int) $this->term2
->id(),
'name' => $this->term2
->label(),
],
],
],
],
[
$this->user,
[],
[],
],
[
$this->file,
[],
[],
],
[
$this->term1,
[],
[],
],
// Make sure we also support configuration entities.
[
$this->vocabulary,
[],
[],
],
[
$this->nodeType,
[],
[],
],
[
$this->role,
[],
[],
],
];
array_walk($entities, function ($data) {
list($entity, $include_fields, $expected_includes) = $data;
$this
->assertEntity($entity, $include_fields, $expected_includes);
});
}