function OptionsFieldUIAllowedValuesTest::providerTestOptionsAllowedValues

Same name in other branches
  1. 11.x core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php \Drupal\Tests\options\FunctionalJavascript\OptionsFieldUIAllowedValuesTest::providerTestOptionsAllowedValues()

Data provider for testOptionsAllowedValues().

Return value

array Array of arrays with the following elements:

  • Option type.
  • Array of option type values.
  • Whether option type is string type or not.
  • The method which should be used to add another row to the table. The possible values are 'Press button', 'Enter button' or 'Enter element'.

File

core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php, line 302

Class

OptionsFieldUIAllowedValuesTest
Tests the Options field allowed values UI functionality.

Namespace

Drupal\Tests\options\FunctionalJavascript

Code

public static function providerTestOptionsAllowedValues() {
    $type_cases = [
        'List integer' => [
            'list_integer',
            [
                1 => 'First',
                2 => 'Second',
                3 => 'Third',
            ],
            FALSE,
        ],
        'List float' => [
            'list_float',
            [
                '0.1' => 'First',
                '0.2' => 'Second',
                '0.3' => 'Third',
            ],
            FALSE,
        ],
        'List string' => [
            'list_string',
            [
                'first' => 'First',
                'second' => 'Second',
                'third' => 'Third',
            ],
            TRUE,
        ],
    ];
    // Test adding options for each option field type using several possible
    // methods that could be used for navigating the options list:
    // - Press button: add a new item by pressing the 'Add another item'
    // button using mouse.
    // - Enter button: add a new item by pressing the 'Add another item'
    // button using enter key on the keyboard.
    // - Enter element: add a new item by pressing enter on the last text
    // field inside the table.
    $test_cases = [];
    foreach ($type_cases as $key => $type_case) {
        foreach ([
            'Press button',
            'Enter button',
            'Enter element',
        ] as $add_more_method) {
            $test_cases["{$key}: {$add_more_method}"] = array_merge($type_case, [
                $add_more_method,
            ]);
        }
    }
    return $test_cases;
}

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