You are here

public function SelectOtherInstallTestScript::createOptions in CCK Select Other 8

Create select list options.

Parameters

int $num: The number of options to create.

string $type: The field type.

Return value

array An associative array of allowed values keyed by value and the label as the array item value.

1 call to SelectOtherInstallTestScript::createOptions()
SelectOtherInstallTestScript::setup in tests/src/TestSite/SelectOtherInstallTestScript.php
Run the code to setup the test environment.

File

tests/src/TestSite/SelectOtherInstallTestScript.php, line 220

Class

SelectOtherInstallTestScript
Setup file used for cck_select_other Nightwatch tests.

Namespace

Drupal\Tests\cck_select_other\TestSite

Code

public function createOptions($num = 5, $type = 'list_string') {
  $options = [];
  for ($i = 0; $i < $num; $i++) {
    if ($type === 'list_string') {
      $label = $this
        ->getRandomGenerator()
        ->word(10);
      $key = strtolower($label);
    }
    else {
      $label = $i;
      $key = $i;
    }
    $options[$key] = $label;
  }
  return $options;
}