function JsonApiDocumentTopLevelNormalizerTest::denormalizeUuidProviderBuilder

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::denormalizeUuidProviderBuilder()
  2. 8.9.x core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::denormalizeUuidProviderBuilder()
  3. 10 core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::denormalizeUuidProviderBuilder()

We cannot use a PHPUnit data provider because our data depends on $this.

Parameters

array $options: Options for how to construct test data.

Return value

array The test data.

1 call to JsonApiDocumentTopLevelNormalizerTest::denormalizeUuidProviderBuilder()
JsonApiDocumentTopLevelNormalizerTest::testDenormalizeUuid in core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php
Try to POST a node and check if it exists afterwards.

File

core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php, line 706

Class

JsonApiDocumentTopLevelNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

protected function denormalizeUuidProviderBuilder(array $options) {
    [
        $input,
        $expected,
    ] = $options;
    [
        $input_tag_uuids,
        $input_user_uuid,
    ] = $input;
    [
        $expected_tag_ids,
        $expected_user_id,
    ] = $expected;
    $node = [
        [
            'data' => [
                'type' => 'node--article',
                'attributes' => [
                    'title' => 'Testing article',
                ],
                'relationships' => [
                    'uid' => [
                        'data' => [
                            'type' => 'user--user',
                            'id' => $input_user_uuid,
                        ],
                    ],
                    'field_tags' => [
                        'data' => [],
                    ],
                ],
            ],
        ],
        [
            'tag_ids' => $expected_tag_ids,
            'user_id' => $expected_user_id,
        ],
    ];
    if (isset($input_tag_uuids[0])) {
        $node[0]['data']['relationships']['field_tags']['data'][0] = [
            'type' => 'taxonomy_term--tags',
            'id' => $input_tag_uuids[0],
        ];
    }
    if (isset($input_tag_uuids[1])) {
        $node[0]['data']['relationships']['field_tags']['data'][1] = [
            'type' => 'taxonomy_term--tags',
            'id' => $input_tag_uuids[1],
        ];
    }
    return $node;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.