You are here

public function CckSelectOtherTestBase::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.

7 calls to CckSelectOtherTestBase::createOptions()
CckSelectOtherDefaultValueTest::testDefaultValue in tests/src/Functional/CckSelectOtherDefaultValueTest.php
Asserts that default value is selected.
CckSelectOtherEmptyTest::testEmpty in tests/src/Functional/CckSelectOtherEmptyTest.php
Asserts field validation for required attribute.
CckSelectOtherFieldTypeTest::testField in tests/src/Functional/CckSelectOtherFieldTypeTest.php
Asserts that a user can save regular and other field values.
CckSelectOtherHtmlEntitiesTest::testHtmlEntities in tests/src/Functional/CckSelectOtherHtmlEntitiesTest.php
Asserts HTML entities are not double-encoded.
CckSelectOtherMultipleFieldTest::setUp in tests/src/Functional/CckSelectOtherMultipleFieldTest.php

... See full list

File

tests/src/Functional/CckSelectOtherTestBase.php, line 146

Class

CckSelectOtherTestBase
CCK Select Other functional test base class.

Namespace

Drupal\Tests\cck_select_other\Functional

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