function FieldInputValueNormalizerTraitTest::keyValueByDeltaTestCases

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Field/FieldInputValueNormalizerTraitTest.php \Drupal\Tests\Core\Field\FieldInputValueNormalizerTraitTest::keyValueByDeltaTestCases()
  2. 10 core/tests/Drupal/Tests/Core/Field/FieldInputValueNormalizerTraitTest.php \Drupal\Tests\Core\Field\FieldInputValueNormalizerTraitTest::keyValueByDeltaTestCases()
  3. 11.x core/tests/Drupal/Tests/Core/Field/FieldInputValueNormalizerTraitTest.php \Drupal\Tests\Core\Field\FieldInputValueNormalizerTraitTest::keyValueByDeltaTestCases()

Provides test cases for ::testKeyValueByDelta.

File

core/tests/Drupal/Tests/Core/Field/FieldInputValueNormalizerTraitTest.php, line 27

Class

FieldInputValueNormalizerTraitTest
@coversDefaultClass \Drupal\Core\Field\FieldInputValueNormalizerTrait @group Field

Namespace

Drupal\Tests\Core\Field

Code

public function keyValueByDeltaTestCases() {
    return [
        'Integer' => [
            1,
            [
                [
                    'value' => 1,
                ],
            ],
        ],
        'Falsey integer' => [
            0,
            [
                [
                    'value' => 0,
                ],
            ],
        ],
        'String' => [
            'foo',
            [
                [
                    'value' => 'foo',
                ],
            ],
        ],
        'Empty string' => [
            '',
            [
                [
                    'value' => '',
                ],
            ],
        ],
        'Null' => [
            NULL,
            [],
        ],
        'Empty field value' => [
            [],
            [],
        ],
        'Single delta' => [
            [
                'value' => 'foo',
            ],
            [
                [
                    'value' => 'foo',
                ],
            ],
        ],
        'Keyed delta' => [
            [
                [
                    'value' => 'foo',
                ],
            ],
            [
                [
                    'value' => 'foo',
                ],
            ],
        ],
        'Multiple keyed deltas' => [
            [
                [
                    'value' => 'foo',
                ],
                [
                    'value' => 'bar',
                ],
            ],
            [
                [
                    'value' => 'foo',
                ],
                [
                    'value' => 'bar',
                ],
            ],
        ],
        'No main property with keyed delta' => [
            [
                [
                    'foo' => 'bar',
                ],
            ],
            [
                [
                    'foo' => 'bar',
                ],
            ],
            NULL,
        ],
        'No main property with single delta' => [
            [
                'foo' => 'bar',
            ],
            [
                [
                    'foo' => 'bar',
                ],
            ],
            NULL,
        ],
        'No main property with empty array' => [
            [],
            [],
            NULL,
        ],
    ];
}

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