function RelationshipNormalizerTest::normalizeProvider

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

Data provider for testNormalize.

File

core/modules/jsonapi/tests/src/Kernel/Normalizer/RelationshipNormalizerTest.php, line 263

Class

RelationshipNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\RelationshipNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

public function normalizeProvider() {
    return [
        'single cardinality' => [
            [
                'user1',
            ],
            'field_user',
            [
                'data' => [
                    'type' => 'user--user',
                    'id' => static::$userIds[0],
                    'meta' => [
                        'drupal_internal__target_id' => static::$userUids[0],
                    ],
                ],
            ],
        ],
        'multiple cardinality' => [
            [
                'user1',
                'user2',
            ],
            'field_users',
            [
                'data' => [
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[0],
                        'meta' => [
                            'drupal_internal__target_id' => static::$userUids[0],
                        ],
                    ],
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[1],
                        'meta' => [
                            'drupal_internal__target_id' => static::$userUids[1],
                        ],
                    ],
                ],
            ],
        ],
        'multiple cardinality, all same values' => [
            [
                'user1',
                'user1',
            ],
            'field_users',
            [
                'data' => [
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[0],
                        'meta' => [
                            'arity' => 0,
                            'drupal_internal__target_id' => static::$userUids[0],
                        ],
                    ],
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[0],
                        'meta' => [
                            'arity' => 1,
                            'drupal_internal__target_id' => static::$userUids[0],
                        ],
                    ],
                ],
            ],
        ],
        'multiple cardinality, some same values' => [
            [
                'user1',
                'user2',
                'user1',
            ],
            'field_users',
            [
                'data' => [
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[0],
                        'meta' => [
                            'arity' => 0,
                            'drupal_internal__target_id' => static::$userUids[0],
                        ],
                    ],
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[1],
                        'meta' => [
                            'drupal_internal__target_id' => static::$userUids[1],
                        ],
                    ],
                    [
                        'type' => 'user--user',
                        'id' => static::$userIds[0],
                        'meta' => [
                            'arity' => 1,
                            'drupal_internal__target_id' => static::$userUids[0],
                        ],
                    ],
                ],
            ],
        ],
        'single cardinality, with meta' => [
            [
                'image1',
            ],
            'field_image',
            [
                'data' => [
                    'type' => 'file--file',
                    'id' => static::$imageIds[0],
                    'meta' => [
                        'alt' => 'Cute llama',
                        'title' => 'My spirit animal',
                        'width' => NULL,
                        'height' => NULL,
                        'drupal_internal__target_id' => static::$imageUids[0],
                    ],
                ],
            ],
        ],
        'multiple cardinality, all same values, with meta' => [
            [
                'image1',
                'image1',
            ],
            'field_images',
            [
                'data' => [
                    [
                        'type' => 'file--file',
                        'id' => static::$imageIds[0],
                        'meta' => [
                            'alt' => 'Cute llama',
                            'title' => 'My spirit animal',
                            'width' => NULL,
                            'height' => NULL,
                            'arity' => 0,
                            'drupal_internal__target_id' => static::$imageUids[0],
                        ],
                    ],
                    [
                        'type' => 'file--file',
                        'id' => static::$imageIds[0],
                        'meta' => [
                            'alt' => 'Cute llama',
                            'title' => 'My spirit animal',
                            'width' => NULL,
                            'height' => NULL,
                            'arity' => 1,
                            'drupal_internal__target_id' => static::$imageUids[0],
                        ],
                    ],
                ],
            ],
        ],
        'multiple cardinality, some same values with same values but different meta' => [
            [
                'image1',
                'image1',
                'image1a',
            ],
            'field_images',
            [
                'data' => [
                    [
                        'type' => 'file--file',
                        'id' => static::$imageIds[0],
                        'meta' => [
                            'alt' => 'Cute llama',
                            'title' => 'My spirit animal',
                            'width' => NULL,
                            'height' => NULL,
                            'arity' => 0,
                            'drupal_internal__target_id' => static::$imageUids[0],
                        ],
                    ],
                    [
                        'type' => 'file--file',
                        'id' => static::$imageIds[0],
                        'meta' => [
                            'alt' => 'Cute llama',
                            'title' => 'My spirit animal',
                            'width' => NULL,
                            'height' => NULL,
                            'arity' => 1,
                            'drupal_internal__target_id' => static::$imageUids[0],
                        ],
                    ],
                    [
                        'type' => 'file--file',
                        'id' => static::$imageIds[0],
                        'meta' => [
                            'alt' => 'Ugly llama',
                            'title' => 'My alter ego',
                            'width' => NULL,
                            'height' => NULL,
                            'arity' => 2,
                            'drupal_internal__target_id' => static::$imageUids[0],
                        ],
                    ],
                ],
            ],
        ],
    ];
}

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