You are here

public function FieldInputValueNormalizerTraitTest::keyValueByDeltaTestCases in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Field/FieldInputValueNormalizerTraitTest.php \Drupal\Tests\Core\Field\FieldInputValueNormalizerTraitTest::keyValueByDeltaTestCases()

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,
    ],
  ];
}