You are here

protected function JsonApiDocumentTopLevelNormalizerTest::denormalizeUuidProviderBuilder in JSON:API 8

Same name and namespace in other branches
  1. 8.2 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 tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php
Try to POST a node and check if it exists afterwards.

File

tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php, line 628

Class

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

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

protected function denormalizeUuidProviderBuilder(array $options) {
  list($input, $expected) = $options;
  list($input_tag_uuids, $input_user_uuid) = $input;
  list($expected_tag_ids, $expected_user_id) = $expected;
  $node = [
    [
      'data' => [
        'type' => 'node--article',
        'attributes' => [
          'title' => 'Testing article',
          'id' => '33095485-70D2-4E51-A309-535CC5BC0115',
        ],
        '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;
}