You are here

public function FormStateValuesTraitTest::providerSetValue in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::providerSetValue()

Provides data to self::testSetValue().

Return value

array[] Items are arrays of two items:

  • The key for which to set a new value (string)
  • The new value to set (mixed).
  • The expected form state values after setting the new value (mixed[]).

File

core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php, line 131

Class

FormStateValuesTraitTest
@coversDefaultClass \Drupal\Core\Form\FormStateValuesTrait

Namespace

Drupal\Tests\Core\Form

Code

public function providerSetValue() {
  $data = [];
  $data[] = [
    'foo',
    'one',
    [
      'bar' => 'wrong',
      'foo' => 'one',
    ],
  ];
  $data[] = [
    [
      'bar',
      'baz',
    ],
    'two',
    [
      'bar' => [
        'baz' => 'two',
      ],
    ],
  ];
  $data[] = [
    [
      'foo',
      'bar',
      'baz',
    ],
    NULL,
    [
      'bar' => 'wrong',
      'foo' => [
        'bar' => [
          'baz' => NULL,
        ],
      ],
    ],
  ];
  return $data;
}